dogescript-3
Version:
an unofficial third version of dogescript
1,548 lines (1,465 loc) • 272 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 = function(program) {return program;},
peg$c2 = { type: "other", description: "end of statement" },
peg$c3 = ";",
peg$c4 = { type: "literal", value: ";", description: "\";\"" },
peg$c5 = { type: "other", description: "end of file" },
peg$c6 = void 0,
peg$c7 = { type: "any", description: "any character" },
peg$c8 = { type: "other", description: "any character" },
peg$c9 = function(char) {return char;},
peg$c10 = "'",
peg$c11 = { type: "literal", value: "'", description: "\"'\"" },
peg$c12 = "\"",
peg$c13 = { type: "literal", value: "\"", description: "\"\\\"\"" },
peg$c14 = { type: "other", description: "whitespace" },
peg$c15 = "\t",
peg$c16 = { type: "literal", value: "\t", description: "\"\\t\"" },
peg$c17 = "\x0B",
peg$c18 = { type: "literal", value: "\x0B", description: "\"\\x0B\"" },
peg$c19 = "\f",
peg$c20 = { type: "literal", value: "\f", description: "\"\\f\"" },
peg$c21 = " ",
peg$c22 = { type: "literal", value: " ", description: "\" \"" },
peg$c23 = "\xA0",
peg$c24 = { type: "literal", value: "\xA0", description: "\"\\xA0\"" },
peg$c25 = "\uFEFF",
peg$c26 = { type: "literal", value: "\uFEFF", description: "\"\\uFEFF\"" },
peg$c27 = /^[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,
peg$c28 = { type: "class", value: "[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]", description: "[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]" },
peg$c29 = { type: "other", description: "end of line" },
peg$c30 = /^[\n\r\u2028\u2029]/,
peg$c31 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" },
peg$c32 = { type: "other", description: "end of line sequence" },
peg$c33 = "\n",
peg$c34 = { type: "literal", value: "\n", description: "\"\\n\"" },
peg$c35 = "\r\n",
peg$c36 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" },
peg$c37 = "\r",
peg$c38 = { type: "literal", value: "\r", description: "\"\\r\"" },
peg$c39 = "\u2028",
peg$c40 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" },
peg$c41 = "\u2029",
peg$c42 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" },
peg$c43 = { type: "other", description: "comment" },
peg$c44 = "quiet",
peg$c45 = { type: "literal", value: "quiet", description: "\"quiet\"" },
peg$c46 = [],
peg$c47 = "loud",
peg$c48 = { type: "literal", value: "loud", description: "\"loud\"" },
peg$c49 = "shh",
peg$c50 = { type: "literal", value: "shh", description: "\"shh\"" },
peg$c51 = { type: "other", description: "newline" },
peg$c52 = /^[\n\r]/,
peg$c53 = { type: "class", value: "[\\n\\r]", description: "[\\n\\r]" },
peg$c54 = "very",
peg$c55 = { type: "literal", value: "very", description: "\"very\"" },
peg$c56 = "always",
peg$c57 = { type: "literal", value: "always", description: "\"always\"" },
peg$c58 = "is",
peg$c59 = { type: "literal", value: "is", description: "\"is\"" },
peg$c60 = "as",
peg$c61 = { type: "literal", value: "as", description: "\"as\"" },
peg$c62 = "wow",
peg$c63 = { type: "literal", value: "wow", description: "\"wow\"" },
peg$c64 = "trained",
peg$c65 = { type: "literal", value: "trained", description: "\"trained\"" },
peg$c66 = "so",
peg$c67 = { type: "literal", value: "so", description: "\"so\"" },
peg$c68 = "out",
peg$c69 = { type: "literal", value: "out", description: "\"out\"" },
peg$c70 = "debooger",
peg$c71 = { type: "literal", value: "debooger", description: "\"debooger\"" },
peg$c72 = "bark",
peg$c73 = { type: "literal", value: "bark", description: "\"bark\"" },
peg$c74 = "this",
peg$c75 = { type: "literal", value: "this", description: "\"this\"" },
peg$c76 = "such",
peg$c77 = { type: "literal", value: "such", description: "\"such\"" },
peg$c78 = "plz",
peg$c79 = { type: "literal", value: "plz", description: "\"plz\"" },
peg$c80 = "dose",
peg$c81 = { type: "literal", value: "dose", description: "\"dose\"" },
peg$c82 = "rly",
peg$c83 = { type: "literal", value: "rly", description: "\"rly\"" },
peg$c84 = "but",
peg$c85 = { type: "literal", value: "but", description: "\"but\"" },
peg$c86 = "many",
peg$c87 = { type: "literal", value: "many", description: "\"many\"" },
peg$c88 = "much",
peg$c89 = { type: "literal", value: "much", description: "\"much\"" },
peg$c90 = "notrly",
peg$c91 = { type: "literal", value: "notrly", description: "\"notrly\"" },
peg$c92 = "dogeof",
peg$c93 = { type: "literal", value: "dogeof", description: "\"dogeof\"" },
peg$c94 = "maybe",
peg$c95 = { type: "literal", value: "maybe", description: "\"maybe\"" },
peg$c96 = "yes",
peg$c97 = { type: "literal", value: "yes", description: "\"yes\"" },
peg$c98 = "no",
peg$c99 = { type: "literal", value: "no", description: "\"no\"" },
peg$c100 = "empty",
peg$c101 = { type: "literal", value: "empty", description: "\"empty\"" },
peg$c102 = "retrieve",
peg$c103 = { type: "literal", value: "retrieve", description: "\"retrieve\"" },
peg$c104 = "typeof",
peg$c105 = { type: "literal", value: "typeof", description: "\"typeof\"" },
peg$c106 = "true",
peg$c107 = { type: "literal", value: "true", description: "\"true\"" },
peg$c108 = "false",
peg$c109 = { type: "literal", value: "false", description: "\"false\"" },
peg$c110 = "null",
peg$c111 = { type: "literal", value: "null", description: "\"null\"" },
peg$c112 = "void",
peg$c113 = { type: "literal", value: "void", description: "\"void\"" },
peg$c114 = "delete",
peg$c115 = { type: "literal", value: "delete", description: "\"delete\"" },
peg$c116 = "catch",
peg$c117 = { type: "literal", value: "catch", description: "\"catch\"" },
peg$c118 = "new",
peg$c119 = { type: "literal", value: "new", description: "\"new\"" },
peg$c120 = "not",
peg$c121 = { type: "literal", value: "not", description: "\"not\"" },
peg$c122 = "smaller",
peg$c123 = { type: "literal", value: "smaller", description: "\"smaller\"" },
peg$c124 = "smallerish",
peg$c125 = { type: "literal", value: "smallerish", description: "\"smallerish\"" },
peg$c126 = "bigger",
peg$c127 = { type: "literal", value: "bigger", description: "\"bigger\"" },
peg$c128 = "biggerish",
peg$c129 = { type: "literal", value: "biggerish", description: "\"biggerish\"" },
peg$c130 = "shibeof",
peg$c131 = { type: "literal", value: "shibeof", description: "\"shibeof\"" },
peg$c132 = "instanceof",
peg$c133 = { type: "literal", value: "instanceof", description: "\"instanceof\"" },
peg$c134 = "with",
peg$c135 = { type: "literal", value: "with", description: "\"with\"" },
peg$c136 = "more",
peg$c137 = { type: "literal", value: "more", description: "\"more\"" },
peg$c138 = "less",
peg$c139 = { type: "literal", value: "less", description: "\"less\"" },
peg$c140 = "lots",
peg$c141 = { type: "literal", value: "lots", description: "\"lots\"" },
peg$c142 = "few",
peg$c143 = { type: "literal", value: "few", description: "\"few\"" },
peg$c144 = "in",
peg$c145 = { type: "literal", value: "in", description: "\"in\"" },
peg$c146 = "next",
peg$c147 = { type: "literal", value: "next", description: "\"next\"" },
peg$c148 = "throw",
peg$c149 = { type: "literal", value: "throw", description: "\"throw\"" },
peg$c150 = "try",
peg$c151 = { type: "literal", value: "try", description: "\"try\"" },
peg$c152 = "and",
peg$c153 = { type: "literal", value: "and", description: "\"and\"" },
peg$c154 = "or",
peg$c155 = { type: "literal", value: "or", description: "\"or\"" },
peg$c156 = "also",
peg$c157 = { type: "literal", value: "also", description: "\"also\"" },
peg$c158 = null,
peg$c159 = function(body) {
return {
"type": "Program",
"body": optionalList(body)
};
},
peg$c160 = function(first, rest) {return buildList(first, rest, 1);},
peg$c161 = function(type, decl) {
return {
"type": "VariableDeclaration",
"declarations": decl,
"kind": type
};
},
peg$c162 = function() {return "var"},
peg$c163 = function() {return "const"},
peg$c164 = ",",
peg$c165 = { type: "literal", value: ",", description: "\",\"" },
peg$c166 = function(first, rest) { return buildList(first, rest, 3); },
peg$c167 = function(iden, expr) {
return {
type: "VariableDeclarator",
id: iden,
init: extractOptional(expr, 3)
};
},
peg$c168 = "=",
peg$c169 = { type: "literal", value: "=", description: "\"=\"" },
peg$c170 = function(left, right) {
return {
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": left,
"right": right
}
};
},
peg$c171 = function(v) {
return {
"type": "ReturnStatement",
"argument": v
}
},
peg$c172 = function(expr) {
return {
"type": "ExpressionStatement",
"expression": expr
}
},
peg$c173 = function() {
return {
"type": "ExpressionStatement",
"expression": {
"type": "Literal",
"value": "use strict"
}
}
},
peg$c174 = function(str, as) {
var _as = optionalList(extractOptional(as, 3));
var asName;
if ('name' in _as) asName = _as['name'];
else if ('value' in _as) asName = _as['value'];
else if ('name' in str) asName = str['name'];
else if ('value' in str) asName = str['value'];
return {
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": moduleName(asName)
},
"init": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": str['name'] || str['value']
}
]
}
}
],
"kind": "var"
}
},
peg$c175 = function(expr) {
return {
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "module"
},
"property": {
"type": "Identifier",
"name": "exports"
}
},
"right": expr
}
};
},
peg$c176 = function() {
return {
"type": "DebuggerStatement"
}
},
peg$c177 = function() {
return {
"type": "BreakStatement"
}
},
peg$c178 = function(left) {
return {
"type": "BlockStatement",
"body": optionalList(left)
};
},
peg$c179 = function() {
return {
"type": "ThisExpression"
};
},
peg$c180 = function(name) {return name;},
peg$c181 = { type: "other", description: "identifier" },
peg$c182 = function(first, rest) {
return {
"type": "Identifier",
"name": first + rest.join("")
};
},
peg$c183 = /^[a-zA-Z]/,
peg$c184 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" },
peg$c185 = "$",
peg$c186 = { type: "literal", value: "$", description: "\"$\"" },
peg$c187 = "_",
peg$c188 = { type: "literal", value: "_", description: "\"_\"" },
peg$c189 = /^[0-9]/,
peg$c190 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c191 = function() { return { type: "Literal", value: null }; },
peg$c192 = function() { return { type: "Literal", value: true }; },
peg$c193 = function() { return { type: "Literal", value: false }; },
peg$c194 = function() { return maybeOP; },
peg$c195 = function(literal) {return literal;},
peg$c196 = ".",
peg$c197 = { type: "literal", value: ".", description: "\".\"" },
peg$c198 = function() { return { "type": "Literal", "value": parseDecLiteral(text()) }; },
peg$c199 = "0",
peg$c200 = { type: "literal", value: "0", description: "\"0\"" },
peg$c201 = /^[1-9]/,
peg$c202 = { type: "class", value: "[1-9]", description: "[1-9]" },
peg$c203 = "e",
peg$c204 = { type: "literal", value: "e", description: "\"e\"" },
peg$c205 = /^[+\-]/,
peg$c206 = { type: "class", value: "[+\\-]", description: "[+\\-]" },
peg$c207 = { type: "other", description: "string" },
peg$c208 = function(chars) {
return { type: "Literal", value: chars.join("") };
},
peg$c209 = "\\",
peg$c210 = { type: "literal", value: "\\", description: "\"\\\\\"" },
peg$c211 = function() { return text(); },
peg$c212 = function(sequence) { return sequence; },
peg$c213 = function() { return ""; },
peg$c214 = function() { return "\0"; },
peg$c215 = "b",
peg$c216 = { type: "literal", value: "b", description: "\"b\"" },
peg$c217 = function() { return "\b"; },
peg$c218 = "f",
peg$c219 = { type: "literal", value: "f", description: "\"f\"" },
peg$c220 = function() { return "\f"; },
peg$c221 = "n",
peg$c222 = { type: "literal", value: "n", description: "\"n\"" },
peg$c223 = function() { return "\n"; },
peg$c224 = "r",
peg$c225 = { type: "literal", value: "r", description: "\"r\"" },
peg$c226 = function() { return "\r"; },
peg$c227 = "t",
peg$c228 = { type: "literal", value: "t", description: "\"t\"" },
peg$c229 = function() { return "\t"; },
peg$c230 = "v",
peg$c231 = { type: "literal", value: "v", description: "\"v\"" },
peg$c232 = function() { return "\v"; },
peg$c233 = "{",
peg$c234 = { type: "literal", value: "{", description: "\"{\"" },
peg$c235 = "}",
peg$c236 = { type: "literal", value: "}", description: "\"}\"" },
peg$c237 = function() {return { "type": "ObjectExpression", "properties": [] };},
peg$c238 = function(obj) {return { "type": "ObjectExpression", "properties": obj };},
peg$c239 = function(first, rest) {
return buildList(first, rest, 3);
},
peg$c240 = ":",
peg$c241 = { type: "literal", value: ":", description: "\":\"" },
peg$c242 = function(key, value) {
return {
"key": key,
"value": value,
"kind": "init"
}
},
peg$c243 = "{{",
peg$c244 = { type: "literal", value: "{{", description: "\"{{\"" },
peg$c245 = "}}",
peg$c246 = { type: "literal", value: "}}", description: "\"}}\"" },
peg$c247 = function() { return { "type": "ObjectExpression", "properties": [] }; },
peg$c248 = function(obj) { return { "type": "ObjectExpression", "properties": obj }; },
peg$c249 = function(member) { return optionalList(member); },
peg$c250 = "!",
peg$c251 = { type: "literal", value: "!", description: "\"!\"" },
peg$c252 = "?",
peg$c253 = { type: "literal", value: "?", description: "\"?\"" },
peg$c254 = function(elements) {
return {
"type": "ArrayExpression",
"elements": elements
}
},
peg$c255 = function() {return {"type": "Identifier", "name": true}},
peg$c256 = function() {return {"type": "Identifier", "name": false}},
peg$c257 = function() {return {"type": "Identifier", "name": null}},
peg$c258 = "[",
peg$c259 = { type: "literal", value: "[", description: "\"[\"" },
peg$c260 = "]",
peg$c261 = { type: "literal", value: "]", description: "\"]\"" },
peg$c262 = function(elision) {
return {
type: "ArrayExpression",
elements: optionalList(extractOptional(elision, 0))
};
},
peg$c263 = function(elements) {
return {
type: "ArrayExpression",
elements: elements
};
},
peg$c264 = function(elements, elision) {
return {
type: "ArrayExpression",
elements: elements.concat(optionalList(extractOptional(elision, 0)))
};
},
peg$c265 = function(elision, element) {
return optionalList(extractOptional(elision, 0)).concat(element);
},
peg$c266 = function(first, rest) { return Array.prototype.concat.apply(first, rest); },
peg$c267 = function(commas) { return filledArray(commas.length + 1, null); },
peg$c268 = "(",
peg$c269 = { type: "literal", value: "(", description: "\"(\"" },
peg$c270 = ")",
peg$c271 = { type: "literal", value: ")", description: "\")\"" },
peg$c272 = function(left) {return left;},
peg$c273 = function(first, rest) { return buildBinaryExpression(first, rest); },
peg$c274 = "+",
peg$c275 = { type: "literal", value: "+", description: "\"+\"" },
peg$c276 = "-",
peg$c277 = { type: "literal", value: "-", description: "\"-\"" },
peg$c278 = "*",
peg$c279 = { type: "literal", value: "*", description: "\"*\"" },
peg$c280 = "/",
peg$c281 = { type: "literal", value: "/", description: "\"/\"" },
peg$c282 = "%",
peg$c283 = { type: "literal", value: "%", description: "\"%\"" },
peg$c284 = function(first, rest) { return buildLogicalExpression(first, rest); },
peg$c285 = "||",
peg$c286 = { type: "literal", value: "||", description: "\"||\"" },
peg$c287 = function() {return "||"},
peg$c288 = "&&",
peg$c289 = { type: "literal", value: "&&", description: "\"&&\"" },
peg$c290 = function() {return "&&"},
peg$c291 = function(argument, operator) {
return {
"type": "UpdateExpression",
"operator": operator,
"argument": argument,
"prefix": false
};
},
peg$c292 = "++",
peg$c293 = { type: "literal", value: "++", description: "\"++\"" },
peg$c294 = "--",
peg$c295 = { type: "literal", value: "--", description: "\"--\"" },
peg$c296 = function(op, argument) {
return {
"type": "UnaryExpression",
"operator": op,
"argument": argument,
"prefix": true
};
},
peg$c297 = function() {return "typeof"},
peg$c298 = function() {return "!"},
peg$c299 = "~",
peg$c300 = { type: "literal", value: "~", description: "\"~\"" },
peg$c301 = "!==",
peg$c302 = { type: "literal", value: "!==", description: "\"!==\"" },
peg$c303 = function() {return "!=="},
peg$c304 = "===",
peg$c305 = { type: "literal", value: "===", description: "\"===\"" },
peg$c306 = function() {return "==="},
peg$c307 = "==",
peg$c308 = { type: "literal", value: "==", description: "\"==\"" },
peg$c309 = "!=",
peg$c310 = { type: "literal", value: "!=", description: "\"!=\"" },
peg$c311 = "<=",
peg$c312 = { type: "literal", value: "<=", description: "\"<=\"" },
peg$c313 = function() {return "<="},
peg$c314 = "<",
peg$c315 = { type: "literal", value: "<", description: "\"<\"" },
peg$c316 = function() {return "<"},
peg$c317 = ">=",
peg$c318 = { type: "literal", value: ">=", description: "\">=\"" },
peg$c319 = function() {return ">="},
peg$c320 = ">",
peg$c321 = { type: "literal", value: ">", description: "\">\"" },
peg$c322 = function() {return ">"},
peg$c323 = function() {return "instanceof"},
peg$c324 = function(iden, args) {
return {
"type": "CallExpression",
"callee": iden,
"arguments": optionalList(extractOptional(args, 3))
}
},
peg$c325 = function(iden, args) { return { "type": "CallExpression", "callee": iden, "arguments": args }; },
peg$c326 = function(iden, args) {
return {
"type": "NewExpression",
"callee": iden,
"arguments": extractOptionalList(args, 3)
}
},
peg$c327 = function(left, right) {
return {
"type": "AssignmentExpression",
"operator": "=",
"left": left,
"right": right
};
},
peg$c328 = function(left, op, right) {
return {
"type": "AssignmentExpression",
"operator": op,
"left": left,
"right": right
};
},
peg$c329 = function() {return "="},
peg$c330 = "+=",
peg$c331 = { type: "literal", value: "+=", description: "\"+=\"" },
peg$c332 = function() {return "+="},
peg$c333 = "-=",
peg$c334 = { type: "literal", value: "-=", description: "\"-=\"" },
peg$c335 = function() {return "-="},
peg$c336 = "*=",
peg$c337 = { type: "literal", value: "*=", description: "\"*=\"" },
peg$c338 = function() {return "*="},
peg$c339 = "/=",
peg$c340 = { type: "literal", value: "/=", description: "\"/=\"" },
peg$c341 = function() {return "/="},
peg$c342 = function(test, consequent, alternate) { return { "type": "ConditionalExpression", "test": test, "consequent": consequent, "alternate": alternate }; },
peg$c343 = function(iden, args) {
return {
"type": "NewExpression",
"callee": iden,
"arguments": optionalList(extractOptional(args, 3))
}
},
peg$c344 = function(property) {
return {"property": property, "computed": true}
},
peg$c345 = function(property) {
return {"property": property, "computed": false}
},
peg$c346 = function(first, rest) {
return buildTree(first, rest, function(result, element) {
return {
type: "MemberExpression",
object: result,
property: element.property,
computed: element.computed
};
});
},
peg$c347 = function(iden, block) {
return {
"type": "FunctionDeclaration",
"id": iden,
"params": [],
"body": block,
"generator": false,
"expression": false
}
},
peg$c348 = function(iden, args, block) {
return {
"type": "FunctionDeclaration",
"id": iden,
"params": args,
"body": block,
"generator": false,
"expression": false
}
},
peg$c349 = function(body) {
return {
"type": "FunctionExpression",
"id": null,
"params": [],
"body": body
};
},
peg$c350 = function(params, body) {
return {
"type": "FunctionExpression",
"id": null,
"params": params,
"body": body
};
},
peg$c351 = { type: "other", description: "arguments" },
peg$c352 = function(test, block) {
return {
"type": "IfStatement",
"test": test,
"consequent": block,
"alternate": null
};
},
peg$c353 = function(test, block, _else) {
return {
"type": "IfStatement",
"test": test,
"consequent": block,
"alternate": _else
};
},
peg$c354 = function(block) {return block;},
peg$c355 = function(test, block) {
return {
"type": "WhileStatement",
"test": test,
"body": block
};
},
peg$c356 = function(init, test, update, body) {
return {
"type": "ForStatement",
"init": extractOptional(init, 0),
"test": extractOptional(test, 0),
"update": update || null,
"body": body
};
},
peg$c357 = function(declarations, test, update, body) {
return {
"type": "ForStatement",
"init": {
"type": "VariableDeclaration",
"declarations": declarations,
"kind": "var"
},
"test": extractOptional(test, 0),
"update": update || null,
"body": body
};
},
peg$c358 = function(left, right, body) {
return {
"type": "ForInStatement",
"left": left,
"right": right,
"body": body
};
},
peg$c359 = function(declarations, right, body) {
return {
"type": "ForInStatement",
"left": {
"type": "VariableDeclaration",
"declarations": declarations,
"kind": "var"
},
"right": right,
"body": body
};
},
peg$c360 = function(block, handler, finalizer) {
return {
"type": "TryStatement",
"block": block,
"handler": handler,
"finalizer": finalizer
};
},
peg$c361 = function(block, handler) {
return {
"type": "TryStatement",
"block": block,
"handler": handler,
"finalizer": null
};
},
peg$c362 = function(block, finalizer) {
return {
"type": "TryStatement",
"block": block,
"handler": null,
"finalizer": finalizer
};
},
peg$c363 = function(param, body) {
return {
"type": "CatchClause",
"param": param,
"body": body
};
},
peg$c364 = function(body) {
return body;
},
peg$c365 = function(left) {
return {
"type": "ThrowStatement",
"argument": left
};
},
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, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parse__();
if (s1 !== peg$FAILED) {
s2 = peg$parseProgram();
if (s2 !== peg$FAILED) {
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c1(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$parseEOS() {
var s0, s1;
peg$silentFails++;
s0 = peg$parseEOF();
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s0 = peg$c3;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s0 === peg$FAILED) {
s0 = peg$parseLineTerminator();
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c2); }
}
return s0;
}
function peg$parseEOF() {
var s0, s1;
peg$silentFails++;
s0 = peg$currPos;
peg$silentFails++;
if (input.length > peg$currPos) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
peg$silentFails--;
if (s1 === peg$FAILED) {
s0 = peg$c6;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
return s0;
}
function peg$parseSourceCharacter() {
var s0, s1;
peg$silentFails++;
if (input.length > peg$currPos) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
return s0;
}
function peg$parseSourceCharacterNoTerm() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parseLineTerminator();
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c6;
} else {
peg$currPos = s1;
s1 = peg$c0;
}
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$c7); }
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c9(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseSourceCharacterNoQuote1() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
if (input.charCodeAt(peg$currPos) === 39) {
s2 = peg$c10;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c6;
} else {
peg$currPos = s1;
s1 = peg$c0;
}
if (s1 !== peg$FAILED) {
s2 = peg$parseSourceCharacterNoTerm();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c9(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseSourceCharacterNoQuote2() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
if (input.charCodeAt(peg$currPos) === 34) {
s2 = peg$c12;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c6;
} else {
peg$currPos = s1;
s1 = peg$c0;
}
if (s1 !== peg$FAILED) {
s2 = peg$parseSourceCharacterNoTerm();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c9(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseWhiteSpace() {
var s0, s1;
peg$silentFails++;
if (input.charCodeAt(peg$currPos) === 9) {
s0 = peg$c15;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 11) {
s0 = peg$c17;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c18); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 12) {
s0 = peg$c19;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c20); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 32) {
s0 = peg$c21;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 160) {
s0 = peg$c23;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 65279) {
s0 = peg$c25;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c26); }
}
if (s0 === peg$FAILED) {
if (peg$c27.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c28); }
}
}
}
}
}
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c14); }
}
return s0;
}
function peg$parseLineTerminator() {
var s0, s1;
peg$silentFails++;
if (peg$c30.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c31); }
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
}
return s0;
}
function peg$parseLineTerminatorSequence() {
var s0, s1;
peg$silentFails++;
if (input.charCodeAt(peg$currPos) === 10) {
s0 = peg$c33;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c34); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c35) {
s0 = peg$c35;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c36); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 13) {
s0 = peg$c37;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c38); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8232) {
s0 = peg$c39;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c40); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8233) {
s0 = peg$c41;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c42); }
}
}
}
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
}
return s0;
}
function peg$parseComment() {
var s0, s1;
peg$silentFails++;
s0 = peg$parseSingleLineComment();
if (s0 === peg$FAILED) {
s0 = peg$parseMultiLineComment();
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
return s0;
}
function peg$parseMultiLineComment() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
if (input.substr(peg$currPos, 5) === peg$c44) {
s1 = peg$c44;
peg$currPos += 5;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
if (input.substr(peg$currPos, 4) === peg$c47) {
s5 = peg$c47;
peg$currPos += 4;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c6;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseSourceCharacter();
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
if (input.substr(peg$currPos, 4) === peg$c47) {
s5 = peg$c47;
peg$currPos += 4;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c6;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseSourceCharacter();
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
}
if (s2 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c47) {
s3 = peg$c47;
peg$currPos += 4;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
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$parseMultiLineCommentNoLineTerminator() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
if (input.substr(peg$currPos, 5) === peg$c44) {
s1 = peg$c44;
peg$currPos += 5;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
if (input.substr(peg$currPos, 4) === peg$c47) {
s5 = peg$c47;
peg$currPos += 4;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
if (s5 === peg$FAILED) {
s5 = peg$parseLineTerminator();
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c6;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseSourceCharacter();
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
if (input.substr(peg$currPos, 4) === peg$c47) {
s5 = peg$c47;
peg$currPos += 4;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
if (s5 === peg$FAILED) {
s5 = peg$parseLineTerminator();
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c6;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseSourceCharacter();
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
}
if (s2 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c47) {
s3 = peg$c47;
peg$currPos += 4;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
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$parseSingleLineComment() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c49) {
s1 = peg$c49;
peg$currPos += 3;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c50); }
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
s5 = peg$parseLineTerminator();
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c6;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseSourceCharacter();
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
s5 = peg$parseLineTerminator();
peg$sile