eggtended-js
Version:
A extended version of the Egg programming language from the Eloquent Javascript book.
1,386 lines (1,385 loc) • 145 kB
JSON
{
"type": "File",
"start": 0,
"end": 604,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 23,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 604,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 23,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 42
}
},
"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": 41,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 41
}
},
"extra": {
"rawValue": "./environment.js",
"raw": "\"./environment.js\""
},
"value": "./environment.js"
}
},
{
"type": "ImportDeclaration",
"start": 43,
"end": 87,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 44
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 52,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
}
},
"imported": {
"type": "Identifier",
"start": 52,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
},
"identifierName": "Parser"
},
"name": "Parser"
},
"local": {
"type": "Identifier",
"start": 52,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
},
"identifierName": "Parser"
},
"name": "Parser"
}
}
],
"source": {
"type": "StringLiteral",
"start": 66,
"end": 86,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 43
}
},
"extra": {
"rawValue": "../parser/parse.js",
"raw": "\"../parser/parse.js\""
},
"value": "../parser/parse.js"
}
},
{
"type": "ImportDeclaration",
"start": 88,
"end": 135,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 47
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 97,
"end": 108,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 20
}
},
"imported": {
"type": "Identifier",
"start": 97,
"end": 108,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 20
},
"identifierName": "SymbolTable"
},
"name": "SymbolTable"
},
"local": {
"type": "Identifier",
"start": 97,
"end": 108,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 20
},
"identifierName": "SymbolTable"
},
"name": "SymbolTable"
}
}
],
"source": {
"type": "StringLiteral",
"start": 116,
"end": 134,
"loc": {
"start": {
"line": 3,
"column": 28
},
"end": {
"line": 3,
"column": 46
}
},
"extra": {
"rawValue": "./symboltable.js",
"raw": "\"./symboltable.js\""
},
"value": "./symboltable.js"
}
},
{
"type": "ExpressionStatement",
"start": 137,
"end": 519,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 19,
"column": 2
}
},
"expression": {
"type": "AssignmentExpression",
"start": 137,
"end": 518,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 19,
"column": 1
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 137,
"end": 154,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 17
}
},
"object": {
"type": "Identifier",
"start": 137,
"end": 143,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 6
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
},
"property": {
"type": "StringLiteral",
"start": 144,
"end": 153,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 16
}
},
"extra": {
"rawValue": "require",
"raw": "\"require\""
},
"value": "require"
},
"computed": true
},
"right": {
"type": "ArrowFunctionExpression",
"start": 157,
"end": 518,
"loc": {
"start": {
"line": 5,
"column": 20
},
"end": {
"line": 19,
"column": 1
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 157,
"end": 161,
"loc": {
"start": {
"line": 5,
"column": 20
},
"end": {
"line": 5,
"column": 24
},
"identifierName": "file"
},
"name": "file"
}
],
"body": {
"type": "BlockStatement",
"start": 165,
"end": 518,
"loc": {
"start": {
"line": 5,
"column": 28
},
"end": {
"line": 19,
"column": 1
}
},
"body": [
{
"type": "IfStatement",
"start": 169,
"end": 467,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 16,
"column": 3
}
},
"test": {
"type": "UnaryExpression",
"start": 173,
"end": 207,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 40
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "BinaryExpression",
"start": 175,
"end": 206,
"loc": {
"start": {
"line": 6,
"column": 8
},
"end": {
"line": 6,
"column": 39
}
},
"left": {
"type": "Identifier",
"start": 175,
"end": 179,
"loc": {
"start": {
"line": 6,
"column": 8
},
"end": {
"line": 6,
"column": 12
},
"identifierName": "file"
},
"name": "file"
},
"operator": "in",
"right": {
"type": "MemberExpression",
"start": 183,
"end": 206,
"loc": {
"start": {
"line": 6,
"column": 16
},
"end": {
"line": 6,
"column": 39
}
},
"object": {
"type": "MemberExpression",
"start": 183,
"end": 200,
"loc": {
"start": {
"line": 6,
"column": 16
},
"end": {
"line": 6,
"column": 33
}
},
"object": {
"type": "Identifier",
"start": 183,
"end": 189,
"loc": {
"start": {
"line": 6,
"column": 16
},
"end": {
"line": 6,
"column": 22
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
},
"property": {
"type": "StringLiteral",
"start": 190,
"end": 199,
"loc": {
"start": {
"line": 6,
"column": 23
},
"end": {
"line": 6,
"column": 32
}
},
"extra": {
"rawValue": "require",
"raw": "\"require\""
},
"value": "require"
},
"computed": true
},
"property": {
"type": "Identifier",
"start": 201,
"end": 206,
"loc": {
"start": {
"line": 6,
"column": 34
},
"end": {
"line": 6,
"column": 39
},
"identifierName": "cache"
},
"name": "cache"
},
"computed": false
},
"extra": {
"parenthesized": true,
"parenStart": 174
}
},
"extra": {
"parenthesizedArgument": false
}
},
"consequent": {
"type": "BlockStatement",
"start": 209,
"end": 467,
"loc": {
"start": {
"line": 6,
"column": 42
},
"end": {
"line": 16,
"column": 3
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 215,
"end": 255,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 7,
"column": 44
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 221,
"end": 254,
"loc": {
"start": {
"line": 7,
"column": 10
},
"end": {
"line": 7,
"column": 43
}
},
"id": {
"type": "Identifier",
"start": 221,
"end": 225,
"loc": {
"start": {
"line": 7,
"column": 10
},
"end": {
"line": 7,
"column": 14
},
"identifierName": "tree"
},
"name": "tree"
},
"init": {
"type": "CallExpression",
"start": 228,
"end": 254,
"loc": {
"start": {
"line": 7,
"column": 17
},
"end": {
"line": 7,
"column": 43
}
},
"callee": {
"type": "MemberExpression",
"start": 228,
"end": 248,
"loc": {
"start": {
"line": 7,
"column": 17
},
"end": {
"line": 7,
"column": 37
}
},
"object": {
"type": "Identifier",
"start": 228,
"end": 234,
"loc": {
"start": {
"line": 7,
"column": 17
},
"end": {
"line": 7,
"column": 23
},
"identifierName": "Parser"
},
"name": "Parser"
},
"property": {
"type": "Identifier",
"start": 235,
"end": 248,
"loc": {
"start": {
"line": 7,
"column": 24
},
"end": {
"line": 7,
"column": 37
},
"identifierName": "parseFromFile"
},
"name": "parseFromFile"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 249,
"end": 253,
"loc": {
"start": {
"line": 7,
"column": 38
},
"end": {
"line": 7,
"column": 42
},
"identifierName": "file"
},
"name": "file"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 260,
"end": 294,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 8,
"column": 38
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 266,
"end": 293,
"loc": {
"start": {
"line": 8,
"column": 10
},
"end": {
"line": 8,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 266,
"end": 269,
"loc": {
"start": {
"line": 8,
"column": 10
},
"end": {
"line": 8,
"column": 13
},
"identifierName": "env"
},
"name": "env"
},
"init": {
"type": "CallExpression",
"start": 272,
"end": 293,
"loc": {
"start": {
"line": 8,
"column": 16
},
"end": {
"line": 8,
"column": 37
}
},
"callee": {
"type": "MemberExpression",
"start": 272,
"end": 285,
"loc": {
"start": {
"line": 8,
"column": 16
},
"end": {
"line": 8,
"column": 29
}
},
"object": {
"type": "Identifier",
"start": 272,
"end": 278,
"loc": {
"start": {
"line": 8,
"column": 16
},
"end": {
"line": 8,
"column": 22
},
"identifierName": "Object"
},
"name": "Object"
},
"property": {
"type": "Identifier",
"start": 279,
"end": 285,
"loc": {
"start": {
"line": 8,
"column": 23
},
"end": {
"line": 8,
"column": 29
},
"identifierName": "create"
},
"name": "create"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 286,
"end": 292,
"loc": {
"start": {
"line": 8,
"column": 30
},
"end": {
"line": 8,
"column": 36
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
}
]
}
}
],
"kind": "const"
},
{
"type": "ExpressionStatement",
"start": 299,
"end": 337,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 42
}
},
"expression": {
"type": "AssignmentExpression",
"start": 299,
"end": 336,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 41
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 299,
"end": 316,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 21
}
},
"object": {
"type": "Identifier",
"start": 299,
"end": 302,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 7
},
"identifierName": "env"
},
"name": "env"
},
"property": {
"type": "StringLiteral",
"start": 303,
"end": 315,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 20
}
},
"extra": {
"rawValue": "__symbol__",
"raw": "\"__symbol__\""
},
"value": "__symbol__"
},
"computed": true
},
"right": {
"type": "NewExpression",
"start": 319,
"end": 336,
"loc": {
"start": {
"line": 9,
"column": 24
},
"end": {
"line": 9,
"column": 41
}
},
"callee": {
"type": "Identifier",
"start": 323,
"end": 334,
"loc": {
"start": {
"line": 9,
"column": 28
},
"end": {
"line": 9,
"column": 39
},
"identifierName": "SymbolTable"
},
"name": "SymbolTable"
},
"arguments": []
}
}
},
{
"type": "ExpressionStatement",
"start": 343,
"end": 362,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 11,
"column": 23
}
},
"expression": {
"type": "CallExpression",
"start": 343,
"end": 361,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 11,
"column": 22
}
},
"callee": {
"type": "MemberExpression",
"start": 343,
"end": 356,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 11,
"column": 17
}
},
"object": {
"type": "Identifier",
"start": 343,
"end": 347,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 11,
"column": 8
},
"identifierName": "tree"
},
"name": "tree"
},
"property": {
"type": "Identifier",
"start": 348,
"end": 356,
"loc": {
"start": {
"line": 11,
"column": 9
},
"end": {
"line": 11,
"column": 17
},
"identifierName": "evaluate"
},
"name": "evaluate"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 357,
"end": 360,
"loc": {
"start": {
"line": 11,
"column": 18
},
"end": {
"line": 11,
"column": 21
},
"identifierName": "env"
},
"name": "env"
}
]
}
},
{
"type": "VariableDeclaration",
"start": 368,
"end": 418,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 54
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 374,
"end": 417,
"loc": {
"start": {
"line": 13,
"column": 10
},
"end": {
"line": 13,
"column": 53
}
},
"id": {
"type": "Identifier",
"start": 374,
"end": 380,
"loc": {
"start": {
"line": 13,
"column": 10
},
"end": {
"line": 13,
"column": 16
},
"identifierName": "module"
},
"name": "module"
},
"init": {
"type": "ObjectExpression",
"start": 383,
"end": 417,
"loc": {
"start": {
"line": 13,
"column": 19
},
"end": {
"line": 13,
"column": 53
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 385,
"end": 415,
"loc": {
"start": {
"line": 13,
"column": 21
},
"end": {
"line": 13,
"column": 51
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 385,
"end": 392,
"loc": {
"start": {
"line": 13,
"column": 21
},
"end": {
"line": 13,
"column": 28
},
"identifierName": "exports"
},
"name": "exports"
},
"value": {
"type": "MemberExpression",
"start": 394,
"end": 415,
"loc": {
"start": {
"line": 13,
"column": 30
},
"end": {
"line": 13,
"column": 51
}
},
"object": {
"type": "MemberExpression",
"start": 394,
"end": 407,
"loc": {
"start": {
"line": 13,
"column": 30
},
"end": {
"line": 13,
"column": 43
}
},
"object": {
"type": "Identifier",
"start": 394,
"end": 397,
"loc": {
"start": {
"line": 13,
"column": 30
},
"end": {
"line": 13,
"column": 33
},
"identifierName": "env"
},
"name": "env"
},
"property": {
"type": "StringLiteral",
"start": 398,
"end": 406,
"loc": {
"start": {
"line": 13,
"column": 34
},
"end": {
"line": 13,
"column": 42
}
},
"extra": {
"rawValue": "module",
"raw": "\"module\""
},
"value": "module"
},
"computed": true
},
"property": {
"type": "Identifier",
"start": 408,
"end": 415,
"loc": {
"start": {
"line": 13,
"column": 44
},
"end": {
"line": 13,
"column": 51
},
"identifierName": "exports"
},
"name": "exports"
},
"computed": false
}
}
]
}
}
],
"kind": "const"
},
{
"type": "ExpressionStatement",
"start": 424,
"end": 463,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 43
}
},
"expression": {
"type": "AssignmentExpression",
"start": 424,
"end": 462,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 42
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 424,
"end": 453,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 33
}
},
"object": {
"type": "MemberExpression",
"start": 424,
"end": 447,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 27
}
},
"object": {
"type": "MemberExpression",
"start": 424,
"end": 441,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 21
}
},
"object": {
"type": "Identifier",
"start": 424,
"end": 430,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 10
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
},
"property": {
"type": "StringLiteral",
"start": 431,
"end": 440,
"loc": {
"start": {
"line": 15,
"column": 11
},
"end": {
"line": 15,
"column": 20
}
},
"extra": {
"rawValue": "require",
"raw": "\"require\""
},
"value": "require"
},
"computed": true
},
"property": {
"type": "Identifier",
"start": 442,
"end": 447,
"loc": {
"start": {
"line": 15,
"column": 22
},