UNPKG

eggtended-js

Version:

A extended version of the Egg programming language from the Eloquent Javascript book.

1,622 lines 303 kB
{ "type": "File", "start": 0, "end": 1167, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 55, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1167, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 55, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 56, "end": 86, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 30 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 63, "end": 85, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 29 } }, "extra": { "rawValue": "./monkey-patching.js", "raw": "\"./monkey-patching.js\"" }, "value": "./monkey-patching.js", "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": " Add monkey-patching functions and extended functions", "start": 0, "end": 55, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 55 } } } ] }, { "type": "ImportDeclaration", "start": 87, "end": 109, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 22 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 94, "end": 108, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 21 } }, "extra": { "rawValue": "./require.js", "raw": "\"./require.js\"" }, "value": "./require.js" } }, { "type": "ImportDeclaration", "start": 110, "end": 131, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 21 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 117, "end": 130, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 20 } }, "extra": { "rawValue": "./arithm.js", "raw": "\"./arithm.js\"" }, "value": "./arithm.js" } }, { "type": "ImportDeclaration", "start": 132, "end": 157, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 25 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 139, "end": 156, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 24 } }, "extra": { "rawValue": "./exceptions.js", "raw": "\"./exceptions.js\"" }, "value": "./exceptions.js" } }, { "type": "ImportDeclaration", "start": 158, "end": 179, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 21 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 165, "end": 178, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 20 } }, "extra": { "rawValue": "./typing.js", "raw": "\"./typing.js\"" }, "value": "./typing.js" } }, { "type": "ImportDeclaration", "start": 181, "end": 201, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 20 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 188, "end": 190, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 9 } }, "local": { "type": "Identifier", "start": 188, "end": 190, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 9 }, "identifierName": "fs" }, "name": "fs" } } ], "source": { "type": "StringLiteral", "start": 196, "end": 200, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 8, "column": 19 } }, "extra": { "rawValue": "fs", "raw": "\"fs\"" }, "value": "fs" } }, { "type": "ImportDeclaration", "start": 203, "end": 247, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 44 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 212, "end": 218, "loc": { "start": { "line": 10, "column": 9 }, "end": { "line": 10, "column": 15 } }, "imported": { "type": "Identifier", "start": 212, "end": 218, "loc": { "start": { "line": 10, "column": 9 }, "end": { "line": 10, "column": 15 }, "identifierName": "Parser" }, "name": "Parser" }, "local": { "type": "Identifier", "start": 212, "end": 218, "loc": { "start": { "line": 10, "column": 9 }, "end": { "line": 10, "column": 15 }, "identifierName": "Parser" }, "name": "Parser" } } ], "source": { "type": "StringLiteral", "start": 226, "end": 246, "loc": { "start": { "line": 10, "column": 23 }, "end": { "line": 10, "column": 43 } }, "extra": { "rawValue": "../parser/parse.js", "raw": "\"../parser/parse.js\"" }, "value": "../parser/parse.js" } }, { "type": "ImportDeclaration", "start": 248, "end": 290, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 42 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 257, "end": 263, "loc": { "start": { "line": 11, "column": 9 }, "end": { "line": 11, "column": 15 } }, "imported": { "type": "Identifier", "start": 257, "end": 263, "loc": { "start": { "line": 11, "column": 9 }, "end": { "line": 11, "column": 15 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "local": { "type": "Identifier", "start": 257, "end": 263, "loc": { "start": { "line": 11, "column": 9 }, "end": { "line": 11, "column": 15 }, "identifierName": "TopEnv" }, "name": "TopEnv" } } ], "source": { "type": "StringLiteral", "start": 271, "end": 289, "loc": { "start": { "line": 11, "column": 23 }, "end": { "line": 11, "column": 41 } }, "extra": { "rawValue": "./environment.js", "raw": "\"./environment.js\"" }, "value": "./environment.js" } }, { "type": "ImportDeclaration", "start": 291, "end": 340, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 49 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 300, "end": 308, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 17 } }, "imported": { "type": "Identifier", "start": 300, "end": 308, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 17 }, "identifierName": "json2AST" }, "name": "json2AST" }, "local": { "type": "Identifier", "start": 300, "end": 308, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 17 }, "identifierName": "json2AST" }, "name": "json2AST" } } ], "source": { "type": "StringLiteral", "start": 316, "end": 339, "loc": { "start": { "line": 12, "column": 25 }, "end": { "line": 12, "column": 48 } }, "extra": { "rawValue": "../parser/json2AST.js", "raw": "\"../parser/json2AST.js\"" }, "value": "../parser/json2AST.js" } }, { "type": "Identifier", "start": 342, "end": 1147, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 52, "column": 1 } }, "id": { "type": "Identifier", "start": 348, "end": 353, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 11 }, "identifierName": "Eggvm" }, "name": "Eggvm" }, "superClass": null, "body": { "type": "ClassBody", "start": 354, "end": 1147, "loc": { "start": { "line": 14, "column": 12 }, "end": { "line": 52, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 358, "end": 453, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 19, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 365, "end": 368, "loc": { "start": { "line": 15, "column": 9 }, "end": { "line": 15, "column": 12 }, "identifierName": "run" }, "name": "run" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 369, "end": 376, "loc": { "start": { "line": 15, "column": 13 }, "end": { "line": 15, "column": 20 }, "identifierName": "program" }, "name": "program" } ], "body": { "type": "BlockStatement", "start": 378, "end": 453, "loc": { "start": { "line": 15, "column": 22 }, "end": { "line": 19, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 384, "end": 419, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 39 } }, "declarations": [ { "type": "VariableDeclarator", "start": 390, "end": 418, "loc": { "start": { "line": 16, "column": 10 }, "end": { "line": 16, "column": 38 } }, "id": { "type": "Identifier", "start": 390, "end": 394, "loc": { "start": { "line": 16, "column": 10 }, "end": { "line": 16, "column": 14 }, "identifierName": "tree" }, "name": "tree" }, "init": { "type": "CallExpression", "start": 397, "end": 418, "loc": { "start": { "line": 16, "column": 17 }, "end": { "line": 16, "column": 38 } }, "callee": { "type": "MemberExpression", "start": 397, "end": 409, "loc": { "start": { "line": 16, "column": 17 }, "end": { "line": 16, "column": 29 } }, "object": { "type": "Identifier", "start": 397, "end": 403, "loc": { "start": { "line": 16, "column": 17 }, "end": { "line": 16, "column": 23 }, "identifierName": "Parser" }, "name": "Parser" }, "property": { "type": "Identifier", "start": 404, "end": 409, "loc": { "start": { "line": 16, "column": 24 }, "end": { "line": 16, "column": 29 }, "identifierName": "parse" }, "name": "parse" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 410, "end": 417, "loc": { "start": { "line": 16, "column": 30 }, "end": { "line": 16, "column": 37 }, "identifierName": "program" }, "name": "program" } ] } } ], "kind": "const" }, { "type": "ReturnStatement", "start": 425, "end": 449, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 28 } }, "argument": { "type": "CallExpression", "start": 432, "end": 448, "loc": { "start": { "line": 18, "column": 11 }, "end": { "line": 18, "column": 27 } }, "callee": { "type": "MemberExpression", "start": 432, "end": 442, "loc": { "start": { "line": 18, "column": 11 }, "end": { "line": 18, "column": 21 } }, "object": { "type": "Identifier", "start": 432, "end": 437, "loc": { "start": { "line": 18, "column": 11 }, "end": { "line": 18, "column": 16 }, "identifierName": "Eggvm" }, "name": "Eggvm" }, "property": { "type": "Identifier", "start": 438, "end": 442, "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 21 }, "identifierName": "eval" }, "name": "eval" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 443, "end": 447, "loc": { "start": { "line": 18, "column": 22 }, "end": { "line": 18, "column": 26 }, "identifierName": "tree" }, "name": "tree" } ] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 457, "end": 570, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 25, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 464, "end": 475, "loc": { "start": { "line": 21, "column": 9 }, "end": { "line": 21, "column": 20 }, "identifierName": "runFromFile" }, "name": "runFromFile" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 476, "end": 480, "loc": { "start": { "line": 21, "column": 21 }, "end": { "line": 21, "column": 25 }, "identifierName": "file" }, "name": "file" } ], "body": { "type": "BlockStatement", "start": 482, "end": 570, "loc": { "start": { "line": 21, "column": 27 }, "end": { "line": 25, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 488, "end": 534, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 50 } }, "declarations": [ { "type": "VariableDeclarator", "start": 494, "end": 533, "loc": { "start": { "line": 22, "column": 10 }, "end": { "line": 22, "column": 49 } }, "id": { "type": "Identifier", "start": 494, "end": 501, "loc": { "start": { "line": 22, "column": 10 }, "end": { "line": 22, "column": 17 }, "identifierName": "program" }, "name": "program" }, "init": { "type": "CallExpression", "start": 504, "end": 533, "loc": { "start": { "line": 22, "column": 20 }, "end": { "line": 22, "column": 49 } }, "callee": { "type": "MemberExpression", "start": 504, "end": 519, "loc": { "start": { "line": 22, "column": 20 }, "end": { "line": 22, "column": 35 } }, "object": { "type": "Identifier", "start": 504, "end": 506, "loc": { "start": { "line": 22, "column": 20 }, "end": { "line": 22, "column": 22 }, "identifierName": "fs" }, "name": "fs" }, "property": { "type": "Identifier", "start": 507, "end": 519, "loc": { "start": { "line": 22, "column": 23 }, "end": { "line": 22, "column": 35 }, "identifierName": "readFileSync" }, "name": "readFileSync" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 520, "end": 524, "loc": { "start": { "line": 22, "column": 36 }, "end": { "line": 22, "column": 40 }, "identifierName": "file" }, "name": "file" }, { "type": "StringLiteral", "start": 526, "end": 532, "loc": { "start": { "line": 22, "column": 42 }, "end": { "line": 22, "column": 48 } }, "extra": { "rawValue": "utf8", "raw": "\"utf8\"" }, "value": "utf8" } ] } } ], "kind": "const" }, { "type": "ReturnStatement", "start": 540, "end": 566, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 30 } }, "argument": { "type": "CallExpression", "start": 547, "end": 565, "loc": { "start": { "line": 24, "column": 11 }, "end": { "line": 24, "column": 29 } }, "callee": { "type": "MemberExpression", "start": 547, "end": 556, "loc": { "start": { "line": 24, "column": 11 }, "end": { "line": 24, "column": 20 } }, "object": { "type": "Identifier", "start": 547, "end": 552, "loc": { "start": { "line": 24, "column": 11 }, "end": { "line": 24, "column": 16 }, "identifierName": "Eggvm" }, "name": "Eggvm" }, "property": { "type": "Identifier", "start": 553, "end": 556, "loc": { "start": { "line": 24, "column": 17 }, "end": { "line": 24, "column": 20 }, "identifierName": "run" }, "name": "run" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 557, "end": 564, "loc": { "start": { "line": 24, "column": 21 }, "end": { "line": 24, "column": 28 }, "identifierName": "program" }, "name": "program" } ] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 574, "end": 746, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 34, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 581, "end": 591, "loc": { "start": { "line": 27, "column": 9 }, "end": { "line": 27, "column": 19 }, "identifierName": "runFromEVM" }, "name": "runFromEVM" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 592, "end": 596, "loc": { "start": { "line": 27, "column": 20 }, "end": { "line": 27, "column": 24 }, "identifierName": "file" }, "name": "file" } ], "body": { "type": "BlockStatement", "start": 598, "end": 746, "loc": { "start": { "line": 27, "column": 26 }, "end": { "line": 34, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 604, "end": 642, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", "start": 610, "end": 641, "loc": { "start": { "line": 28, "column": 10 }, "end": { "line": 28, "column": 41 } }, "id": { "type": "Identifier", "start": 610, "end": 617, "loc": { "start": { "line": 28, "column": 10 }, "end": { "line": 28, "column": 17 }, "identifierName": "rawData" }, "name": "rawData" }, "init": { "type": "CallExpression", "start": 620, "end": 641, "loc": { "start": { "line": 28, "column": 20 }, "end": { "line": 28, "column": 41 } }, "callee": { "type": "MemberExpression", "start": 620, "end": 635, "loc": { "start": { "line": 28, "column": 20 }, "end": { "line": 28, "column": 35 } }, "object": { "type": "Identifier", "start": 620, "end": 622, "loc": { "start": { "line": 28, "column": 20 }, "end": { "line": 28, "column": 22 }, "identifierName": "fs" }, "name": "fs" }, "property": { "type": "Identifier", "start": 623, "end": 635, "loc": { "start": { "line": 28, "column": 23 }, "end": { "line": 28, "column": 35 }, "identifierName": "readFileSync" }, "name": "readFileSync" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 636, "end": 640, "loc": { "start": { "line": 28, "column": 36 }, "end": { "line": 28, "column": 40 }, "identifierName": "file" }, "name": "file" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 647, "end": 678, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 35 } }, "declarations": [ { "type": "VariableDeclarator", "start": 651, "end": 677, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 34 } }, "id": { "type": "Identifier", "start": 651, "end": 655, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 12 }, "identifierName": "json" }, "name": "json" }, "init": { "type": "CallExpression", "start": 658, "end": 677, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 34 } }, "callee": { "type": "MemberExpression", "start": 658, "end": 668, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 25 } }, "object": { "type": "Identifier", "start": 658, "end": 662, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 19 }, "identifierName": "JSON" }, "name": "JSON" }, "property": { "type": "Identifier", "start": 663, "end": 668, "loc": { "start": { "line": 29, "column": 20 }, "end": { "line": 29, "column": 25 }, "identifierName": "parse" }, "name": "parse" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 669, "end": 676, "loc": { "start": { "line": 29, "column": 26 }, "end": { "line": 29, "column": 33 }, "identifierName": "rawData" }, "name": "rawData" } ] } } ], "kind": "let" }, { "type": "VariableDeclaration", "start": 684, "end": 712, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 32 } }, "declarations": [ { "type": "VariableDeclarator", "start": 690, "end": 711, "loc": { "start": { "line": 31, "column": 10 }, "end": { "line": 31, "column": 31 } }, "id": { "type": "Identifier", "start": 690, "end": 694, "loc": { "start": { "line": 31, "column": 10 }, "end": { "line": 31, "column"