UNPKG

eggtended-js

Version:

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

1,492 lines (1,491 loc) 101 kB
{ "type": "File", "start": 0, "end": 320, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 20, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 320, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 20, "column": 0 } }, "sourceType": "module", "body": [ { "type": "Identifier", "start": 0, "end": 294, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 17, "column": 1 } }, "id": { "type": "Identifier", "start": 6, "end": 17, "loc": { "start": { "line": 1, "column": 6 }, "end": { "line": 1, "column": 17 }, "identifierName": "SymbolTable" }, "name": "SymbolTable" }, "superClass": null, "body": { "type": "ClassBody", "start": 18, "end": 294, "loc": { "start": { "line": 1, "column": 18 }, "end": { "line": 17, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 22, "end": 156, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 8, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 22, "end": 34, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 2, "column": 14 }, "identifierName": "addAttribute" }, "name": "addAttribute" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 35, "end": 44, "loc": { "start": { "line": 2, "column": 15 }, "end": { "line": 2, "column": 24 }, "identifierName": "attribute" }, "name": "attribute" }, { "type": "Identifier", "start": 46, "end": 51, "loc": { "start": { "line": 2, "column": 26 }, "end": { "line": 2, "column": 31 }, "identifierName": "value" }, "name": "value" }, { "type": "Identifier", "start": 53, "end": 57, "loc": { "start": { "line": 2, "column": 33 }, "end": { "line": 2, "column": 37 }, "identifierName": "name" }, "name": "name" } ], "body": { "type": "BlockStatement", "start": 59, "end": 156, "loc": { "start": { "line": 2, "column": 39 }, "end": { "line": 8, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 65, "end": 116, "loc": { "start": { "line": 3, "column": 4 }, "end": { "line": 5, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 69, "end": 84, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 23 } }, "operator": "!", "prefix": true, "argument": { "type": "BinaryExpression", "start": 71, "end": 83, "loc": { "start": { "line": 3, "column": 10 }, "end": { "line": 3, "column": 22 } }, "left": { "type": "Identifier", "start": 71, "end": 75, "loc": { "start": { "line": 3, "column": 10 }, "end": { "line": 3, "column": 14 }, "identifierName": "name" }, "name": "name" }, "operator": "in", "right": { "type": "ThisExpression", "start": 79, "end": 83, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 22 } } }, "extra": { "parenthesized": true, "parenStart": 70 } }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 86, "end": 116, "loc": { "start": { "line": 3, "column": 25 }, "end": { "line": 5, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 94, "end": 110, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 94, "end": 109, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 94, "end": 104, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 16 } }, "object": { "type": "ThisExpression", "start": 94, "end": 98, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 10 } } }, "property": { "type": "Identifier", "start": 99, "end": 103, "loc": { "start": { "line": 4, "column": 11 }, "end": { "line": 4, "column": 15 }, "identifierName": "name" }, "name": "name" }, "computed": true }, "right": { "type": "ObjectExpression", "start": 107, "end": 109, "loc": { "start": { "line": 4, "column": 19 }, "end": { "line": 4, "column": 21 } }, "properties": [] } } } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 122, "end": 152, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 122, "end": 151, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 122, "end": 143, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 25 } }, "object": { "type": "MemberExpression", "start": 122, "end": 132, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 14 } }, "object": { "type": "ThisExpression", "start": 122, "end": 126, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 8 } } }, "property": { "type": "Identifier", "start": 127, "end": 131, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 13 }, "identifierName": "name" }, "name": "name" }, "computed": true }, "property": { "type": "Identifier", "start": 133, "end": 142, "loc": { "start": { "line": 7, "column": 15 }, "end": { "line": 7, "column": 24 }, "identifierName": "attribute" }, "name": "attribute" }, "computed": true }, "right": { "type": "Identifier", "start": 146, "end": 151, "loc": { "start": { "line": 7, "column": 28 }, "end": { "line": 7, "column": 33 }, "identifierName": "value" }, "name": "value" } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 160, "end": 292, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 16, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 160, "end": 174, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 16 }, "identifierName": "checkAttribute" }, "name": "checkAttribute" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 175, "end": 184, "loc": { "start": { "line": 10, "column": 17 }, "end": { "line": 10, "column": 26 }, "identifierName": "attribute" }, "name": "attribute" }, { "type": "Identifier", "start": 186, "end": 190, "loc": { "start": { "line": 10, "column": 28 }, "end": { "line": 10, "column": 32 }, "identifierName": "name" }, "name": "name" } ], "body": { "type": "BlockStatement", "start": 192, "end": 292, "loc": { "start": { "line": 10, "column": 34 }, "end": { "line": 16, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 198, "end": 269, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 13, "column": 5 } }, "test": { "type": "LogicalExpression", "start": 202, "end": 241, "loc": { "start": { "line": 11, "column": 8 }, "end": { "line": 11, "column": 47 } }, "left": { "type": "BinaryExpression", "start": 202, "end": 214, "loc": { "start": { "line": 11, "column": 8 }, "end": { "line": 11, "column": 20 } }, "left": { "type": "Identifier", "start": 202, "end": 206, "loc": { "start": { "line": 11, "column": 8 }, "end": { "line": 11, "column": 12 }, "identifierName": "name" }, "name": "name" }, "operator": "in", "right": { "type": "ThisExpression", "start": 210, "end": 214, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 20 } } } }, "operator": "&&", "right": { "type": "BinaryExpression", "start": 218, "end": 241, "loc": { "start": { "line": 11, "column": 24 }, "end": { "line": 11, "column": 47 } }, "left": { "type": "Identifier", "start": 218, "end": 227, "loc": { "start": { "line": 11, "column": 24 }, "end": { "line": 11, "column": 33 }, "identifierName": "attribute" }, "name": "attribute" }, "operator": "in", "right": { "type": "MemberExpression", "start": 231, "end": 241, "loc": { "start": { "line": 11, "column": 37 }, "end": { "line": 11, "column": 47 } }, "object": { "type": "ThisExpression", "start": 231, "end": 235, "loc": { "start": { "line": 11, "column": 37 }, "end": { "line": 11, "column": 41 } } }, "property": { "type": "Identifier", "start": 236, "end": 240, "loc": { "start": { "line": 11, "column": 42 }, "end": { "line": 11, "column": 46 }, "identifierName": "name" }, "name": "name" }, "computed": true } } }, "consequent": { "type": "BlockStatement", "start": 243, "end": 269, "loc": { "start": { "line": 11, "column": 49 }, "end": { "line": 13, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 251, "end": 263, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 12, "column": 18 } }, "argument": { "type": "BooleanLiteral", "start": 258, "end": 262, "loc": { "start": { "line": 12, "column": 13 }, "end": { "line": 12, "column": 17 } }, "value": true } } ], "directives": [] }, "alternate": null }, { "type": "ReturnStatement", "start": 275, "end": 288, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 17 } }, "argument": { "type": "BooleanLiteral", "start": 282, "end": 287, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 16 } }, "value": false } } ], "directives": [] } } ] }, "name": "_", "leadingComments": [], "trailingComments": [] }, { "type": "ExportNamedDeclaration", "start": 296, "end": 319, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 23 } }, "declaration": null, "specifiers": [ { "type": "ExportSpecifier", "start": 305, "end": 316, "loc": { "start": { "line": 19, "column": 9 }, "end": { "line": 19, "column": 20 } }, "local": { "type": "Identifier", "start": 305, "end": 316, "loc": { "start": { "line": 19, "column": 9 }, "end": { "line": 19, "column": 20 }, "identifierName": "SymbolTable" }, "name": "SymbolTable" }, "exported": { "type": "Identifier", "start": 305, "end": 316, "loc": { "start": { "line": 19, "column": 9 }, "end": { "line": 19, "column": 20 }, "identifierName": "SymbolTable" }, "name": "SymbolTable" } } ], "source": null }, { "type": "ExportNamedDeclaration", "start": 296, "end": 319, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 23 } }, "declaration": { "type": "ClassDeclaration", "start": 0, "end": 294, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 17, "column": 1 } }, "id": { "type": "Identifier", "start": 6, "end": 17, "loc": { "start": { "line": 1, "column": 6 }, "end": { "line": 1, "column": 17 }, "identifierName": "SymbolTable" }, "name": "SymbolTable" }, "superClass": null, "body": { "type": "ClassBody", "start": 18, "end": 294, "loc": { "start": { "line": 1, "column": 18 }, "end": { "line": 17, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 22, "end": 156, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 8, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 22, "end": 34, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 2, "column": 14 }, "identifierName": "addAttribute" }, "name": "addAttribute" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 35, "end": 44, "loc": { "start": { "line": 2, "column": 15 }, "end": { "line": 2, "column": 24 }, "identifierName": "attribute" }, "name": "attribute" }, { "type": "Identifier", "start": 46, "end": 51, "loc": { "start": { "line": 2, "column": 26 }, "end": { "line": 2, "column": 31 }, "identifierName": "value" }, "name": "value" }, { "type": "Identifier", "start": 53, "end": 57, "loc": { "start": { "line": 2, "column": 33 }, "end": { "line": 2, "column": 37 }, "identifierName": "name" }, "name": "name" } ], "body": { "type": "BlockStatement", "start": 59, "end": 156, "loc": { "start": { "line": 2, "column": 39 }, "end": { "line": 8, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 65, "end": 116, "loc": { "start": { "line": 3, "column": 4 }, "end": { "line": 5, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 69, "end": 84, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 23 } }, "operator": "!", "prefix": true, "argument": { "type": "BinaryExpression", "start": 71, "end": 83, "loc": { "start": { "line": 3, "column": 10 }, "end": { "line": 3, "column": 22 } }, "left": { "type": "Identifier", "start": 71, "end": 75, "loc": { "start": { "line": 3, "column": 10 }, "end": { "line": 3, "column": 14 }, "identifierName": "name" }, "name": "name" }, "operator": "in", "right": { "type": "ThisExpression", "start": 79, "end": 83, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 22 } } }, "extra": { "parenthesized": true, "parenStart": 70 } }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 86, "end": 116, "loc": { "start": { "line": 3, "column": 25 }, "end": { "line": 5, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 94, "end": 110, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 94, "end": 109, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 94, "end": 104, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 16 } }, "object": { "type": "ThisExpression", "start": 94, "end": 98, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 10 } } }, "property": { "type": "Identifier", "start": 99, "end": 103, "loc": { "start": { "line": 4, "column": 11 }, "end": { "line": 4, "column": 15 }, "identifierName": "name" }, "name": "name" }, "computed": true }, "right": { "type": "ObjectExpression", "start": 107, "end": 109, "loc": { "start": { "line": 4, "column": 19 }, "end": { "line": 4, "column": 21 } }, "properties": [] } } } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 122, "end": 152, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 122, "end": 151, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 122, "end": 143, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 25 } }, "object": { "type": "MemberExpression", "start": 122, "end": 132, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 14 } }, "object": { "type": "ThisExpression", "start": 122, "end": 126, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 8 } } }, "property": { "type": "Identifier", "start": 127, "end": 131, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 13 }, "identifierName": "name" }, "name": "name" }, "computed": true }, "property": { "type": "Identifier", "start": 133, "end": 142, "loc": { "start": { "line": 7, "column": 15 }, "end": { "line": 7, "column": 24 }, "identifierName": "attribute" }, "name": "attribute" }, "computed": true }, "right": { "type": "Identifier", "start": 146, "end": 151, "loc": { "start": { "line": 7, "column": 28 }, "end": { "line": 7, "column": 33 }, "identifierName": "value" }, "name": "value" } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 160, "end": 292, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 16, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 160, "end": 174, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 16 }, "identifierName": "checkAttribute" }, "name": "checkAttribute" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 175, "end": 184, "loc": { "start": { "line": 10, "column": 17 }, "end": { "line": 10, "column": 26 }, "identifierName": "attribute" }, "name": "attribute" }, { "type": "Identifier", "start": 186, "end": 190, "loc": { "start": { "line": 10, "column": 28 },