UNPKG

eggtended-js

Version:

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

1,859 lines 134 kB
{ "type": "File", "start": 0, "end": 434, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 17, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 434, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 17, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 50, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 50 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 9, "end": 15, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 15 } }, "imported": { "type": "Identifier", "start": 9, "end": 15, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 15 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "local": { "type": "Identifier", "start": 9, "end": 15, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 15 }, "identifierName": "TopEnv" }, "name": "TopEnv" } } ], "source": { "type": "StringLiteral", "start": 23, "end": 49, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 49 } }, "extra": { "rawValue": "../interp/environment.js", "raw": "\"../interp/environment.js\"" }, "value": "../interp/environment.js" } }, { "type": "ImportDeclaration", "start": 51, "end": 83, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 32 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 58, "end": 63, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 12 } }, "local": { "type": "Identifier", "start": 58, "end": 63, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 12 }, "identifierName": "style" }, "name": "style" } } ], "source": { "type": "StringLiteral", "start": 69, "end": 82, "loc": { "start": { "line": 2, "column": 18 }, "end": { "line": 2, "column": 31 } }, "extra": { "rawValue": "ansi-styles", "raw": "\"ansi-styles\"" }, "value": "ansi-styles" } }, { "type": "Identifier", "start": 85, "end": 134, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 49 } }, "declarations": [ { "type": "VariableDeclarator", "start": 91, "end": 133, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 48 } }, "id": { "type": "Identifier", "start": 91, "end": 94, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 9 }, "identifierName": "RED" }, "name": "RED" }, "init": { "type": "AssignmentExpression", "start": 98, "end": 132, "loc": { "start": { "line": 4, "column": 13 }, "end": { "line": 4, "column": 47 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 98, "end": 115, "loc": { "start": { "line": 4, "column": 13 }, "end": { "line": 4, "column": 30 } }, "object": { "type": "Identifier", "start": 98, "end": 104, "loc": { "start": { "line": 4, "column": 13 }, "end": { "line": 4, "column": 19 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "property": { "type": "StringLiteral", "start": 105, "end": 114, "loc": { "start": { "line": 4, "column": 20 }, "end": { "line": 4, "column": 29 } }, "extra": { "rawValue": "__RED__", "raw": "\"__RED__\"" }, "value": "__RED__" }, "computed": true }, "right": { "type": "MemberExpression", "start": 118, "end": 132, "loc": { "start": { "line": 4, "column": 33 }, "end": { "line": 4, "column": 47 } }, "object": { "type": "MemberExpression", "start": 118, "end": 127, "loc": { "start": { "line": 4, "column": 33 }, "end": { "line": 4, "column": 42 } }, "object": { "type": "Identifier", "start": 118, "end": 123, "loc": { "start": { "line": 4, "column": 33 }, "end": { "line": 4, "column": 38 }, "identifierName": "style" }, "name": "style" }, "property": { "type": "Identifier", "start": 124, "end": 127, "loc": { "start": { "line": 4, "column": 39 }, "end": { "line": 4, "column": 42 }, "identifierName": "red" }, "name": "red" }, "computed": false }, "property": { "type": "Identifier", "start": 128, "end": 132, "loc": { "start": { "line": 4, "column": 43 }, "end": { "line": 4, "column": 47 }, "identifierName": "open" }, "name": "open" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 97 } } } ], "kind": "const", "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "Identifier", "start": 135, "end": 190, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 55 } }, "declarations": [ { "type": "VariableDeclarator", "start": 141, "end": 189, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 54 } }, "id": { "type": "Identifier", "start": 141, "end": 146, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 11 }, "identifierName": "GREEN" }, "name": "GREEN" }, "init": { "type": "AssignmentExpression", "start": 150, "end": 188, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 5, "column": 53 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 150, "end": 169, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 5, "column": 34 } }, "object": { "type": "Identifier", "start": 150, "end": 156, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 5, "column": 21 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "property": { "type": "StringLiteral", "start": 157, "end": 168, "loc": { "start": { "line": 5, "column": 22 }, "end": { "line": 5, "column": 33 } }, "extra": { "rawValue": "__GREEN__", "raw": "\"__GREEN__\"" }, "value": "__GREEN__" }, "computed": true }, "right": { "type": "MemberExpression", "start": 172, "end": 188, "loc": { "start": { "line": 5, "column": 37 }, "end": { "line": 5, "column": 53 } }, "object": { "type": "MemberExpression", "start": 172, "end": 183, "loc": { "start": { "line": 5, "column": 37 }, "end": { "line": 5, "column": 48 } }, "object": { "type": "Identifier", "start": 172, "end": 177, "loc": { "start": { "line": 5, "column": 37 }, "end": { "line": 5, "column": 42 }, "identifierName": "style" }, "name": "style" }, "property": { "type": "Identifier", "start": 178, "end": 183, "loc": { "start": { "line": 5, "column": 43 }, "end": { "line": 5, "column": 48 }, "identifierName": "green" }, "name": "green" }, "computed": false }, "property": { "type": "Identifier", "start": 184, "end": 188, "loc": { "start": { "line": 5, "column": 49 }, "end": { "line": 5, "column": 53 }, "identifierName": "open" }, "name": "open" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 149 } } } ], "kind": "const", "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "Identifier", "start": 191, "end": 249, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 58 } }, "declarations": [ { "type": "VariableDeclarator", "start": 197, "end": 248, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 57 } }, "id": { "type": "Identifier", "start": 197, "end": 203, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 12 }, "identifierName": "YELLOW" }, "name": "YELLOW" }, "init": { "type": "AssignmentExpression", "start": 207, "end": 247, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 56 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 207, "end": 227, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 36 } }, "object": { "type": "Identifier", "start": 207, "end": 213, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 22 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "property": { "type": "StringLiteral", "start": 214, "end": 226, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 35 } }, "extra": { "rawValue": "__YELLOW__", "raw": "\"__YELLOW__\"" }, "value": "__YELLOW__" }, "computed": true }, "right": { "type": "MemberExpression", "start": 230, "end": 247, "loc": { "start": { "line": 6, "column": 39 }, "end": { "line": 6, "column": 56 } }, "object": { "type": "MemberExpression", "start": 230, "end": 242, "loc": { "start": { "line": 6, "column": 39 }, "end": { "line": 6, "column": 51 } }, "object": { "type": "Identifier", "start": 230, "end": 235, "loc": { "start": { "line": 6, "column": 39 }, "end": { "line": 6, "column": 44 }, "identifierName": "style" }, "name": "style" }, "property": { "type": "Identifier", "start": 236, "end": 242, "loc": { "start": { "line": 6, "column": 45 }, "end": { "line": 6, "column": 51 }, "identifierName": "yellow" }, "name": "yellow" }, "computed": false }, "property": { "type": "Identifier", "start": 243, "end": 247, "loc": { "start": { "line": 6, "column": 52 }, "end": { "line": 6, "column": 56 }, "identifierName": "open" }, "name": "open" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 206 } } } ], "kind": "const", "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "Identifier", "start": 250, "end": 302, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 52 } }, "declarations": [ { "type": "VariableDeclarator", "start": 256, "end": 301, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 51 } }, "id": { "type": "Identifier", "start": 256, "end": 260, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 10 }, "identifierName": "BLUE" }, "name": "BLUE" }, "init": { "type": "AssignmentExpression", "start": 264, "end": 300, "loc": { "start": { "line": 7, "column": 14 }, "end": { "line": 7, "column": 50 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 264, "end": 282, "loc": { "start": { "line": 7, "column": 14 }, "end": { "line": 7, "column": 32 } }, "object": { "type": "Identifier", "start": 264, "end": 270, "loc": { "start": { "line": 7, "column": 14 }, "end": { "line": 7, "column": 20 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "property": { "type": "StringLiteral", "start": 271, "end": 281, "loc": { "start": { "line": 7, "column": 21 }, "end": { "line": 7, "column": 31 } }, "extra": { "rawValue": "__BLUE__", "raw": "\"__BLUE__\"" }, "value": "__BLUE__" }, "computed": true }, "right": { "type": "MemberExpression", "start": 285, "end": 300, "loc": { "start": { "line": 7, "column": 35 }, "end": { "line": 7, "column": 50 } }, "object": { "type": "MemberExpression", "start": 285, "end": 295, "loc": { "start": { "line": 7, "column": 35 }, "end": { "line": 7, "column": 45 } }, "object": { "type": "Identifier", "start": 285, "end": 290, "loc": { "start": { "line": 7, "column": 35 }, "end": { "line": 7, "column": 40 }, "identifierName": "style" }, "name": "style" }, "property": { "type": "Identifier", "start": 291, "end": 295, "loc": { "start": { "line": 7, "column": 41 }, "end": { "line": 7, "column": 45 }, "identifierName": "blue" }, "name": "blue" }, "computed": false }, "property": { "type": "Identifier", "start": 296, "end": 300, "loc": { "start": { "line": 7, "column": 46 }, "end": { "line": 7, "column": 50 }, "identifierName": "open" }, "name": "open" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 263 } } } ], "kind": "const", "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "Identifier", "start": 303, "end": 359, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 56 } }, "declarations": [ { "type": "VariableDeclarator", "start": 309, "end": 358, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 55 } }, "id": { "type": "Identifier", "start": 309, "end": 316, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 13 }, "identifierName": "DEFAULT" }, "name": "DEFAULT" }, "init": { "type": "AssignmentExpression", "start": 320, "end": 357, "loc": { "start": { "line": 8, "column": 17 }, "end": { "line": 8, "column": 54 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 320, "end": 337, "loc": { "start": { "line": 8, "column": 17 }, "end": { "line": 8, "column": 34 } }, "object": { "type": "Identifier", "start": 320, "end": 326, "loc": { "start": { "line": 8, "column": 17 }, "end": { "line": 8, "column": 23 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "property": { "type": "StringLiteral", "start": 327, "end": 336, "loc": { "start": { "line": 8, "column": 24 }, "end": { "line": 8, "column": 33 } }, "extra": { "rawValue": "__DEF__", "raw": "\"__DEF__\"" }, "value": "__DEF__" }, "computed": true }, "right": { "type": "MemberExpression", "start": 340, "end": 357, "loc": { "start": { "line": 8, "column": 37 }, "end": { "line": 8, "column": 54 } }, "object": { "type": "MemberExpression", "start": 340, "end": 351, "loc": { "start": { "line": 8, "column": 37 }, "end": { "line": 8, "column": 48 } }, "object": { "type": "Identifier", "start": 340, "end": 345, "loc": { "start": { "line": 8, "column": 37 }, "end": { "line": 8, "column": 42 }, "identifierName": "style" }, "name": "style" }, "property": { "type": "Identifier", "start": 346, "end": 351, "loc": { "start": { "line": 8, "column": 43 }, "end": { "line": 8, "column": 48 }, "identifierName": "color" }, "name": "color" }, "computed": false }, "property": { "type": "Identifier", "start": 352, "end": 357, "loc": { "start": { "line": 8, "column": 49 }, "end": { "line": 8, "column": 54 }, "identifierName": "close" }, "name": "close" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 319 } } } ], "kind": "const", "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "ExpressionStatement", "start": 361, "end": 378, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 17 } }, "expression": { "type": "CallExpression", "start": 361, "end": 377, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 16 } }, "callee": { "type": "MemberExpression", "start": 361, "end": 372, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 11 } }, "object": { "type": "Identifier", "start": 361, "end": 368, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 7 }, "identifierName": "console" }, "name": "console" }, "property": { "type": "Identifier", "start": 369, "end": 372, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 11 }, "identifierName": "log" }, "name": "log" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 373, "end": 376, "loc": { "start": { "line": 10, "column": 12 }, "end": { "line": 10, "column": 15 }, "identifierName": "RED" }, "name": "RED" } ] } }, { "type": "ExportNamedDeclaration", "start": 380, "end": 433, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 16, "column": 12 } }, "declaration": null, "specifiers": [ { "type": "ExportSpecifier", "start": 389, "end": 392, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 12 } }, "local": { "type": "Identifier", "start": 389, "end": 392, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 12 }, "identifierName": "RED" }, "name": "RED" }, "exported": { "type": "Identifier", "start": 389, "end": 392, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 12 }, "identifierName": "RED" }, "name": "RED" } }, { "type": "ExportSpecifier", "start": 396, "end": 401, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 7 } }, "local": { "type": "Identifier", "start": 396, "end": 401, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 7 }, "identifierName": "GREEN" }, "name": "GREEN" }, "exported": { "type": "Identifier", "start": 396, "end": 401, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 7 }, "identifierName": "GREEN" }, "name": "GREEN" } }, { "type": "ExportSpecifier", "start": 405, "end": 411, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 8 } }, "local": { "type": "Identifier", "start": 405, "end": 411, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 8 }, "identifierName": "YELLOW" }, "name": "YELLOW" }, "exported": { "type": "Identifier", "start": 405, "end": 411, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 8 }, "identifierName": "YELLOW" }, "name": "YELLOW" } }, { "type": "ExportSpecifier", "start": 415, "end": 419, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 15, "column": 6 } }, "local": { "type": "Identifier", "start": 415, "end": 419, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 15, "column": 6 }, "identifierName": "BLUE" }, "name": "BLUE" }, "exported": { "type": "Identifier", "start": 415, "end": 419, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 15, "column": 6 }, "identifierName": "BLUE" }, "name": "BLUE" } }, { "type": "ExportSpecifier", "start": 423, "end": 430, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 9 } }, "local": { "type": "Identifier", "start": 423, "end": 430, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 9 }, "identifierName": "DEFAULT" }, "name": "DEFAULT" }, "exported": { "type": "Identifier", "start": 423, "end": 430, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 9 }, "identifierName": "DEFAULT" }, "name": "DEFAULT" } } ], "source": null }, { "type": "ExportNamedDeclaration", "start": 380, "end": 433, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 16, "column": 12 } }, "declaration": { "type": "VariableDeclaration", "start": 85, "end": 134, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 49 } }, "declarations": [ { "type": "VariableDeclarator", "start": 91, "end": 133, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 48 } }, "id": { "type": "Identifier", "start": 91, "end": 94, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 9 }, "identifierName": "RED" }, "name": "RED" }, "init": { "type": "AssignmentExpression", "start": 98, "end": 132, "loc": { "start": { "line": 4, "column": 13 }, "end": { "line": 4, "column": 47 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 98, "end": 115, "loc": { "start": { "line": 4, "column": 13 }, "end": { "line": 4, "column": 30 } }, "object": { "type": "Identifier", "start": 98, "end": 104, "loc": { "start": { "line": 4, "column": 13 }, "end": { "line": 4, "column": 19 }, "identifierName": "TopEnv" }, "name": "TopEnv" }, "property": { "type": "StringLiteral", "start": 105, "end": 114, "loc": { "start": { "line": 4, "column": 20 }, "end": { "line": 4, "column": 29 } }, "extra": { "rawValue": "__RED__", "raw": "\"__RED__\"" }, "value": "__RED__" }, "computed": true }, "right": { "type": "MemberExpression", "start": 118, "end": 132, "loc": { "start": { "line": 4, "column": 33 }, "end": { "line": 4, "column": 47 } }, "object": { "type": "MemberExpression", "start": 118, "end": 127, "loc": { "start": { "line": 4, "column": 33 }, "end": { "line": 4, "column": 42 } }, "object": { "type": "Identifier", "start": 118, "end": 123, "loc": { "start": { "line": 4, "column": 33 }, "end": { "line": 4, "column": 38 }, "identifierName": "style" }, "name": "style" }, "property": { "type": "Identifier", "start": 124, "end": 127, "loc": { "start": { "line": 4, "column": 39 }, "end": { "line": 4, "column": 42 }, "identifierName": "red" }, "name": "red" }, "computed": false }, "property": { "type": "Identifier", "start": 128, "end": 132, "loc": { "start": { "line": 4, "column": 43 }, "end": { "line": 4, "column": 47 }, "identifierName": "open" }, "name": "open" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 97 } } } ], "kind": "const", "leadingComments": [], "trailingComments": [] }, "specifiers": null, "source": null, "leadingComments": null }, { "type": "ExportNamedDeclaration", "start": 380, "end": 433, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 16, "column": 12 } }, "declaration": { "type": "VariableDeclaration", "start": 135, "end": 190, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 55 } }, "declarations": [ { "type": "VariableDeclarator", "start": 141, "end": 189, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line