UNPKG

eggtended-js

Version:

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

1,566 lines (1,565 loc) 812 kB
{ "type": "File", "start": 0, "end": 2764, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 121, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2764, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 121, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 19, "end": 49, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 30 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 26, "end": 33, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 } }, "local": { "type": "Identifier", "start": 26, "end": 33, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 }, "identifierName": "xRegExp" }, "name": "xRegExp", "leadingComments": null }, "leadingComments": null } ], "source": { "type": "StringLiteral", "start": 39, "end": 48, "loc": { "start": { "line": 2, "column": 20 }, "end": { "line": 2, "column": 29 } }, "extra": { "rawValue": "xregexp", "raw": "\"xregexp\"" }, "value": "xregexp" }, "leadingComments": [ { "type": "CommentLine", "value": " AST class nodes", "start": 0, "end": 18, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 18 } } } ] }, { "type": "ImportDeclaration", "start": 50, "end": 82, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 32 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 57, "end": 62, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 } }, "local": { "type": "Identifier", "start": 57, "end": 62, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 }, "identifierName": "utils" }, "name": "utils" } } ], "source": { "type": "StringLiteral", "start": 68, "end": 81, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 31 } }, "extra": { "rawValue": "../utils.js", "raw": "\"../utils.js\"" }, "value": "../utils.js" } }, { "type": "ImportDeclaration", "start": 84, "end": 132, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 48 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 93, "end": 105, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 21 } }, "imported": { "type": "Identifier", "start": 93, "end": 105, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 21 }, "identifierName": "SpecialForms" }, "name": "SpecialForms" }, "local": { "type": "Identifier", "start": 93, "end": 105, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 21 }, "identifierName": "SpecialForms" }, "name": "SpecialForms" } } ], "source": { "type": "StringLiteral", "start": 113, "end": 131, "loc": { "start": { "line": 5, "column": 29 }, "end": { "line": 5, "column": 47 } }, "extra": { "rawValue": "./environment.js", "raw": "\"./environment.js\"" }, "value": "./environment.js" } }, { "type": "Identifier", "start": 134, "end": 274, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 16, "column": 1 } }, "id": { "type": "Identifier", "start": 140, "end": 145, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 11 }, "identifierName": "Value" }, "name": "Value" }, "superClass": null, "body": { "type": "ClassBody", "start": 146, "end": 274, "loc": { "start": { "line": 7, "column": 12 }, "end": { "line": 16, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 150, "end": 229, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 11, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 150, "end": 161, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 162, "end": 167, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 19 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 169, "end": 229, "loc": { "start": { "line": 8, "column": 21 }, "end": { "line": 11, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 175, "end": 195, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 24 } }, "expression": { "type": "AssignmentExpression", "start": 175, "end": 194, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 23 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 175, "end": 184, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 13 } }, "object": { "type": "ThisExpression", "start": 175, "end": 179, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 8 } } }, "property": { "type": "Identifier", "start": 180, "end": 184, "loc": { "start": { "line": 9, "column": 9 }, "end": { "line": 9, "column": 13 }, "identifierName": "type" }, "name": "type" }, "computed": false }, "right": { "type": "StringLiteral", "start": 187, "end": 194, "loc": { "start": { "line": 9, "column": 16 }, "end": { "line": 9, "column": 23 } }, "extra": { "rawValue": "value", "raw": "\"value\"" }, "value": "value" } } }, { "type": "ExpressionStatement", "start": 200, "end": 225, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 29 } }, "expression": { "type": "AssignmentExpression", "start": 200, "end": 224, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 28 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 200, "end": 210, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 14 } }, "object": { "type": "ThisExpression", "start": 200, "end": 204, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 8 } } }, "property": { "type": "Identifier", "start": 205, "end": 210, "loc": { "start": { "line": 10, "column": 9 }, "end": { "line": 10, "column": 14 }, "identifierName": "value" }, "name": "value" }, "computed": false }, "right": { "type": "MemberExpression", "start": 213, "end": 224, "loc": { "start": { "line": 10, "column": 17 }, "end": { "line": 10, "column": 28 } }, "object": { "type": "Identifier", "start": 213, "end": 218, "loc": { "start": { "line": 10, "column": 17 }, "end": { "line": 10, "column": 22 }, "identifierName": "token" }, "name": "token" }, "property": { "type": "Identifier", "start": 219, "end": 224, "loc": { "start": { "line": 10, "column": 23 }, "end": { "line": 10, "column": 28 }, "identifierName": "value" }, "name": "value" }, "computed": false } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 233, "end": 272, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 15, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 233, "end": 241, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 10 }, "identifierName": "evaluate" }, "name": "evaluate" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 244, "end": 272, "loc": { "start": { "line": 13, "column": 13 }, "end": { "line": 15, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 250, "end": 268, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 22 } }, "argument": { "type": "MemberExpression", "start": 257, "end": 267, "loc": { "start": { "line": 14, "column": 11 }, "end": { "line": 14, "column": 21 } }, "object": { "type": "ThisExpression", "start": 257, "end": 261, "loc": { "start": { "line": 14, "column": 11 }, "end": { "line": 14, "column": 15 } } }, "property": { "type": "Identifier", "start": 262, "end": 267, "loc": { "start": { "line": 14, "column": 16 }, "end": { "line": 14, "column": 21 }, "identifierName": "value" }, "name": "value" }, "computed": false } } ], "directives": [] } } ] }, "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "Identifier", "start": 276, "end": 708, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 36, "column": 1 } }, "id": { "type": "Identifier", "start": 282, "end": 286, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 10 }, "identifierName": "Word" }, "name": "Word" }, "superClass": null, "body": { "type": "ClassBody", "start": 287, "end": 708, "loc": { "start": { "line": 18, "column": 11 }, "end": { "line": 36, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 291, "end": 368, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 22, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 291, "end": 302, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 19, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 303, "end": 308, "loc": { "start": { "line": 19, "column": 14 }, "end": { "line": 19, "column": 19 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 310, "end": 368, "loc": { "start": { "line": 19, "column": 21 }, "end": { "line": 22, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 316, "end": 335, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 23 } }, "expression": { "type": "AssignmentExpression", "start": 316, "end": 334, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 22 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 316, "end": 325, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 13 } }, "object": { "type": "ThisExpression", "start": 316, "end": 320, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 8 } } }, "property": { "type": "Identifier", "start": 321, "end": 325, "loc": { "start": { "line": 20, "column": 9 }, "end": { "line": 20, "column": 13 }, "identifierName": "type" }, "name": "type" }, "computed": false }, "right": { "type": "StringLiteral", "start": 328, "end": 334, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 22 } }, "extra": { "rawValue": "word", "raw": "\"word\"" }, "value": "word" } } }, { "type": "ExpressionStatement", "start": 340, "end": 364, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 28 } }, "expression": { "type": "AssignmentExpression", "start": 340, "end": 363, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 27 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 340, "end": 349, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 13 } }, "object": { "type": "ThisExpression", "start": 340, "end": 344, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 8 } } }, "property": { "type": "Identifier", "start": 345, "end": 349, "loc": { "start": { "line": 21, "column": 9 }, "end": { "line": 21, "column": 13 }, "identifierName": "name" }, "name": "name" }, "computed": false }, "right": { "type": "MemberExpression", "start": 352, "end": 363, "loc": { "start": { "line": 21, "column": 16 }, "end": { "line": 21, "column": 27 } }, "object": { "type": "Identifier", "start": 352, "end": 357, "loc": { "start": { "line": 21, "column": 16 }, "end": { "line": 21, "column": 21 }, "identifierName": "token" }, "name": "token" }, "property": { "type": "Identifier", "start": 358, "end": 363, "loc": { "start": { "line": 21, "column": 22 }, "end": { "line": 21, "column": 27 }, "identifierName": "value" }, "name": "value" }, "computed": false } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 372, "end": 706, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 35, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 372, "end": 380, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 10 }, "identifierName": "evaluate" }, "name": "evaluate" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 381, "end": 384, "loc": { "start": { "line": 24, "column": 11 }, "end": { "line": 24, "column": 14 }, "identifierName": "env" }, "name": "env" } ], "body": { "type": "BlockStatement", "start": 386, "end": 706, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 35, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 408, "end": 702, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 34, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 412, "end": 428, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 24 } }, "left": { "type": "MemberExpression", "start": 412, "end": 421, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 17 } }, "object": { "type": "ThisExpression", "start": 412, "end": 416, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 417, "end": 421, "loc": { "start": { "line": 26, "column": 13 }, "end": { "line": 26, "column": 17 }, "identifierName": "name" }, "name": "name" }, "computed": false, "leadingComments": null }, "operator": "in", "right": { "type": "Identifier", "start": 425, "end": 428, "loc": { "start": { "line": 26, "column": 21 }, "end": { "line": 26, "column": 24 }, "identifierName": "env" }, "name": "env" }, "leadingComments": null }, "consequent": { "type": "BlockStatement", "start": 430, "end": 524, "loc": { "start": { "line": 26, "column": 26 }, "end": { "line": 30, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 438, "end": 460, "loc": { "start": { "line": 27, "column": 6 }, "end": { "line": 27, "column": 28 } }, "argument": { "type": "MemberExpression", "start": 445, "end": 459, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 27, "column": 27 } }, "object": { "type": "Identifier", "start": 445, "end": 448, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 27, "column": 16 }, "identifierName": "env" }, "name": "env" }, "property": { "type": "MemberExpression", "start": 449, "end": 458, "loc": { "start": { "line": 27, "column": 17 }, "end": { "line": 27, "column": 26 } }, "object": { "type": "ThisExpression", "start": 449, "end": 453, "loc": { "start": { "line": 27, "column": 17 }, "end": { "line": 27, "column": 21 } } }, "property": { "type": "Identifier", "start": 454, "end": 458, "loc": { "start": { "line": 27, "column": 22 }, "end": { "line": 27, "column": 26 }, "identifierName": "name" }, "name": "name" }, "computed": false }, "computed": true }, "trailingComments": [ { "type": "CommentLine", "value": " Object variable referenced without using 'this'", "start": 468, "end": 518, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 56 } } } ] } ], "directives": [] }, "alternate": { "type": "IfStatement", "start": 530, "end": 702, "loc": { "start": { "line": 30, "column": 11 }, "end": { "line": 34, "column": 5 } }, "test": { "type": "LogicalExpression", "start": 534, "end": 575, "loc": { "start": { "line": 30, "column": 15 }, "end": { "line": 30, "column": 56 } }, "left": { "type": "BinaryExpression", "start": 534, "end": 547, "loc": { "start": { "line": 30, "column": 15 }, "end": { "line": 30, "column": 28 } }, "left": { "type": "StringLiteral", "start": 534, "end": 540, "loc": { "start": { "line": 30, "column": 15 }, "end": { "line": 30, "column": 21 } }, "extra": { "rawValue": "this", "raw": "\"this\"" }, "value": "this" }, "operator": "in", "right": { "type": "Identifier", "start": 544, "end": 547, "loc": { "start": { "line": 30, "column": 25 }, "end": { "line": 30, "column": 28 }, "identifierName": "env" }, "name": "env" } }, "operator": "&&", "right": { "type": "BinaryExpression", "start": 551, "end": 575, "loc": { "start": { "line": 30, "column": 32 }, "end": { "line": 30, "column": 56 } }, "left": { "type": "MemberExpression", "start": 551, "end": 560, "loc": { "start": { "line": 30, "column": 32 }, "end": { "line": 30, "column": 41 } }, "object": { "type": "ThisExpression", "start": 551, "end": 555, "loc": { "start": { "line": 30, "column": 32 }, "end": { "line": 30, "column": 36 } } }, "property": { "type": "Identifier", "start": 556, "end": 560, "loc": { "start": { "line": 30, "column": 37 }, "end": { "line": 30, "column": 41 }, "identifierName": "name" }, "name": "name" }, "computed": false }, "operator": "in", "right": { "type": "MemberExpression", "start": 564, "end": 575, "loc": { "start": { "line": 30, "column": 45 }, "end": { "line": 30, "column": 56 } }, "object": {