eggtended-js
Version:
A extended version of the Egg programming language from the Eloquent Javascript book.
1,555 lines (1,554 loc) • 641 kB
JSON
{
"type": "File",
"start": 0,
"end": 1691,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 74,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1691,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 74,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "process"
},
"name": "process"
}
}
],
"source": {
"type": "StringLiteral",
"start": 20,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 29
}
},
"extra": {
"rawValue": "process",
"raw": "\"process\""
},
"value": "process"
}
},
{
"type": "ImportDeclaration",
"start": 31,
"end": 63,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 32
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 38,
"end": 46,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 15
}
},
"local": {
"type": "Identifier",
"start": 38,
"end": 46,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 15
},
"identifierName": "readline"
},
"name": "readline"
}
}
],
"source": {
"type": "StringLiteral",
"start": 52,
"end": 62,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 31
}
},
"extra": {
"rawValue": "readline",
"raw": "\"readline\""
},
"value": "readline"
}
},
{
"type": "ImportDeclaration",
"start": 65,
"end": 108,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 43
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 74,
"end": 79,
"loc": {
"start": {
"line": 4,
"column": 9
},
"end": {
"line": 4,
"column": 14
}
},
"imported": {
"type": "Identifier",
"start": 74,
"end": 79,
"loc": {
"start": {
"line": 4,
"column": 9
},
"end": {
"line": 4,
"column": 14
},
"identifierName": "Lexer"
},
"name": "Lexer"
},
"local": {
"type": "Identifier",
"start": 74,
"end": 79,
"loc": {
"start": {
"line": 4,
"column": 9
},
"end": {
"line": 4,
"column": 14
},
"identifierName": "Lexer"
},
"name": "Lexer"
}
}
],
"source": {
"type": "StringLiteral",
"start": 87,
"end": 107,
"loc": {
"start": {
"line": 4,
"column": 22
},
"end": {
"line": 4,
"column": 42
}
},
"extra": {
"rawValue": "../parser/lexer.js",
"raw": "\"../parser/lexer.js\""
},
"value": "../parser/lexer.js"
}
},
{
"type": "ImportDeclaration",
"start": 109,
"end": 153,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 44
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 118,
"end": 124,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 15
}
},
"imported": {
"type": "Identifier",
"start": 118,
"end": 124,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 15
},
"identifierName": "Parser"
},
"name": "Parser"
},
"local": {
"type": "Identifier",
"start": 118,
"end": 124,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 15
},
"identifierName": "Parser"
},
"name": "Parser"
}
}
],
"source": {
"type": "StringLiteral",
"start": 132,
"end": 152,
"loc": {
"start": {
"line": 5,
"column": 23
},
"end": {
"line": 5,
"column": 43
}
},
"extra": {
"rawValue": "../parser/parse.js",
"raw": "\"../parser/parse.js\""
},
"value": "../parser/parse.js"
}
},
{
"type": "ImportDeclaration",
"start": 154,
"end": 204,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 50
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 163,
"end": 169,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 15
}
},
"imported": {
"type": "Identifier",
"start": 163,
"end": 169,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 15
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
},
"local": {
"type": "Identifier",
"start": 163,
"end": 169,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 15
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
}
}
],
"source": {
"type": "StringLiteral",
"start": 177,
"end": 203,
"loc": {
"start": {
"line": 6,
"column": 23
},
"end": {
"line": 6,
"column": 49
}
},
"extra": {
"rawValue": "../interp/environment.js",
"raw": "\"../interp/environment.js\""
},
"value": "../interp/environment.js"
}
},
{
"type": "ImportDeclaration",
"start": 205,
"end": 248,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 7,
"column": 43
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 214,
"end": 219,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 14
}
},
"imported": {
"type": "Identifier",
"start": 214,
"end": 219,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 14
},
"identifierName": "Eggvm"
},
"name": "Eggvm"
},
"local": {
"type": "Identifier",
"start": 214,
"end": 219,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 14
},
"identifierName": "Eggvm"
},
"name": "Eggvm"
}
}
],
"source": {
"type": "StringLiteral",
"start": 227,
"end": 247,
"loc": {
"start": {
"line": 7,
"column": 22
},
"end": {
"line": 7,
"column": 42
}
},
"extra": {
"rawValue": "../interp/eggvm.js",
"raw": "\"../interp/eggvm.js\""
},
"value": "../interp/eggvm.js"
}
},
{
"type": "ImportDeclaration",
"start": 250,
"end": 291,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 9,
"column": 41
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 257,
"end": 267,
"loc": {
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 9,
"column": 17
}
},
"local": {
"type": "Identifier",
"start": 257,
"end": 267,
"loc": {
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 9,
"column": 17
},
"identifierName": "extensions"
},
"name": "extensions"
}
}
],
"source": {
"type": "StringLiteral",
"start": 273,
"end": 290,
"loc": {
"start": {
"line": 9,
"column": 23
},
"end": {
"line": 9,
"column": 40
}
},
"extra": {
"rawValue": "./extensions.js",
"raw": "\"./extensions.js\""
},
"value": "./extensions.js"
}
},
{
"type": "ImportDeclaration",
"start": 292,
"end": 325,
"loc": {
"start": {
"line": 10,
"column": 0
},
"end": {
"line": 10,
"column": 33
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 299,
"end": 305,
"loc": {
"start": {
"line": 10,
"column": 7
},
"end": {
"line": 10,
"column": 13
}
},
"local": {
"type": "Identifier",
"start": 299,
"end": 305,
"loc": {
"start": {
"line": 10,
"column": 7
},
"end": {
"line": 10,
"column": 13
},
"identifierName": "colors"
},
"name": "colors"
}
}
],
"source": {
"type": "StringLiteral",
"start": 311,
"end": 324,
"loc": {
"start": {
"line": 10,
"column": 19
},
"end": {
"line": 10,
"column": 32
}
},
"extra": {
"rawValue": "./colors.js",
"raw": "\"./colors.js\""
},
"value": "./colors.js"
}
},
{
"type": "Identifier",
"start": 327,
"end": 1672,
"loc": {
"start": {
"line": 12,
"column": 0
},
"end": {
"line": 71,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 333,
"end": 1671,
"loc": {
"start": {
"line": 12,
"column": 6
},
"end": {
"line": 71,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 333,
"end": 337,
"loc": {
"start": {
"line": 12,
"column": 6
},
"end": {
"line": 12,
"column": 10
},
"identifierName": "repl"
},
"name": "repl"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 340,
"end": 1671,
"loc": {
"start": {
"line": 12,
"column": 13
},
"end": {
"line": 71,
"column": 1
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 346,
"end": 1671,
"loc": {
"start": {
"line": 12,
"column": 19
},
"end": {
"line": 71,
"column": 1
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 383,
"end": 420,
"loc": {
"start": {
"line": 14,
"column": 2
},
"end": {
"line": 14,
"column": 39
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 389,
"end": 419,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 38
}
},
"id": {
"type": "Identifier",
"start": 389,
"end": 395,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 14
},
"identifierName": "topEnv"
},
"name": "topEnv",
"leadingComments": null
},
"init": {
"type": "CallExpression",
"start": 398,
"end": 419,
"loc": {
"start": {
"line": 14,
"column": 17
},
"end": {
"line": 14,
"column": 38
}
},
"callee": {
"type": "MemberExpression",
"start": 398,
"end": 411,
"loc": {
"start": {
"line": 14,
"column": 17
},
"end": {
"line": 14,
"column": 30
}
},
"object": {
"type": "Identifier",
"start": 398,
"end": 404,
"loc": {
"start": {
"line": 14,
"column": 17
},
"end": {
"line": 14,
"column": 23
},
"identifierName": "Object"
},
"name": "Object"
},
"property": {
"type": "Identifier",
"start": 405,
"end": 411,
"loc": {
"start": {
"line": 14,
"column": 24
},
"end": {
"line": 14,
"column": 30
},
"identifierName": "create"
},
"name": "create"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 412,
"end": 418,
"loc": {
"start": {
"line": 14,
"column": 31
},
"end": {
"line": 14,
"column": 37
},
"identifierName": "TopEnv"
},
"name": "TopEnv"
}
]
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentLine",
"value": " Create the REPL environment",
"start": 350,
"end": 380,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 13,
"column": 32
}
}
}
]
},
{
"type": "VariableDeclaration",
"start": 423,
"end": 449,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 28
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 429,
"end": 448,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 27
}
},
"id": {
"type": "Identifier",
"start": 429,
"end": 434,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 13
},
"identifierName": "lexer"
},
"name": "lexer"
},
"init": {
"type": "NewExpression",
"start": 437,
"end": 448,
"loc": {
"start": {
"line": 15,
"column": 16
},
"end": {
"line": 15,
"column": 27
}
},
"callee": {
"type": "Identifier",
"start": 441,
"end": 446,
"loc": {
"start": {
"line": 15,
"column": 20
},
"end": {
"line": 15,
"column": 25
},
"identifierName": "Lexer"
},
"name": "Lexer"
},
"arguments": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 452,
"end": 480,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 16,
"column": 30
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 458,
"end": 479,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 29
}
},
"id": {
"type": "Identifier",
"start": 458,
"end": 464,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 14
},
"identifierName": "parser"
},
"name": "parser"
},
"init": {
"type": "NewExpression",
"start": 467,
"end": 479,
"loc": {
"start": {
"line": 16,
"column": 17
},
"end": {
"line": 16,
"column": 29
}
},
"callee": {
"type": "Identifier",
"start": 471,
"end": 477,
"loc": {
"start": {
"line": 16,
"column": 21
},
"end": {
"line": 16,
"column": 27
},
"identifierName": "Parser"
},
"name": "Parser"
},
"arguments": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 484,
"end": 501,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 18,
"column": 19
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 488,
"end": 500,
"loc": {
"start": {
"line": 18,
"column": 6
},
"end": {
"line": 18,
"column": 18
}
},
"id": {
"type": "Identifier",
"start": 488,
"end": 495,
"loc": {
"start": {
"line": 18,
"column": 6
},
"end": {
"line": 18,
"column": 13
},
"identifierName": "program"
},
"name": "program"
},
"init": {
"type": "StringLiteral",
"start": 498,
"end": 500,
"loc": {
"start": {
"line": 18,
"column": 16
},
"end": {
"line": 18,
"column": 18
}
},
"extra": {
"rawValue": "",
"raw": "\"\""
},
"value": ""
}
}
],
"kind": "let"
},
{
"type": "VariableDeclaration",
"start": 504,
"end": 518,
"loc": {
"start": {
"line": 19,
"column": 2
},
"end": {
"line": 19,
"column": 16
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 508,
"end": 517,
"loc": {
"start": {
"line": 19,
"column": 6
},
"end": {
"line": 19,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 508,
"end": 513,
"loc": {
"start": {
"line": 19,
"column": 6
},
"end": {
"line": 19,
"column": 11
},
"identifierName": "stack"
},
"name": "stack"
},
"init": {
"type": "NumericLiteral",
"start": 516,
"end": 517,
"loc": {
"start": {
"line": 19,
"column": 14
},
"end": {
"line": 19,
"column": 15
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"kind": "let"
},
{
"type": "ExpressionStatement",
"start": 522,
"end": 543,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 23
}
},
"expression": {
"type": "CallExpression",
"start": 522,
"end": 542,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 22
}
},
"callee": {
"type": "MemberExpression",
"start": 522,
"end": 540,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 20
}
},
"object": {
"type": "Identifier",
"start": 522,
"end": 532,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 12
},
"identifierName": "extensions"
},
"name": "extensions"
},
"property": {
"type": "Identifier",
"start": 533,
"end": 540,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 20
},
"identifierName": "eggInfo"
},
"name": "eggInfo"
},
"computed": false
},
"arguments": []
}
},
{
"type": "TryStatement",
"start": 547,
"end": 1669,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 70,
"column": 3
}
},
"block": {
"type": "BlockStatement",
"start": 551,
"end": 1603,
"loc": {
"start": {
"line": 23,
"column": 6
},
"end": {
"line": 67,
"column": 3
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 557,
"end": 693,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 26,
"column": 7
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 563,
"end": 692,
"loc": {
"start": {
"line": 24,
"column": 10
},
"end": {
"line": 26,
"column": 6
}
},
"id": {
"type": "Identifier",
"start": 563,
"end": 565,
"loc": {
"start": {
"line": 24,
"column": 10
},
"end": {
"line": 24,
"column": 12
},
"identifierName": "rl"
},
"name": "rl"
},
"init": {
"type": "CallExpression",
"start": 568,
"end": 692,
"loc": {
"start": {
"line": 24,
"column": 15
},
"end": {
"line": 26,
"column": 6
}
},
"callee": {
"type": "MemberExpression",
"start": 568,
"end": 592,
"loc": {
"start": {
"line": 24,
"column": 15
},
"end": {
"line": 24,
"column": 39
}
},
"object": {
"type": "Identifier",
"start": 568,
"end": 576,
"loc": {
"start": {
"line": 24,
"column": 15
},
"end": {
"line": 24,
"column": 23
},
"identifierName": "readline"
},
"name": "readline"
},
"property": {
"type": "Identifier",
"start": 577,
"end": 592,
"loc": {
"start": {
"line": 24,
"column": 24
},
"end": {
"line": 24,
"column": 39
},
"identifierName": "createInterface"
},
"name": "createInterface"
},
"computed": false
},
"arguments": [
{
"type": "MemberExpression",
"start": 593,
"end": 606,
"loc": {
"start": {
"line": 24,
"column": 40
},
"end": {
"line": 24,
"column": 53
}
},
"object": {
"type": "Identifier",
"start": 593,
"end": 600,
"loc": {
"start": {
"line": 24,
"column": 40
},
"end": {
"line": 24,
"column": 47
},
"identifierName": "process"
},
"name": "process"
},
"property": {
"type": "Identifier",
"start": 601,
"end": 606,
"loc": {
"start": {
"line": 24,
"column": 48
},
"end": {
"line": 24,
"column": 53
},
"identifierName": "stdin"
},
"name": "stdin"
},
"computed": false
},
{
"type": "MemberExpression",
"start": 608,
"end": 622,
"loc": {
"start": {
"line": 24,
"column": 55
},
"end": {
"line": 24,
"column": 69
}
},
"object": {
"type": "Identifier",
"start": 608,
"end": 615,
"loc": {
"start": {
"line": 24,
"column": 55
},
"end": {
"line": 24,
"column": 62
},
"identifierName": "process"
},
"name": "process"
},
"property": {
"type": "Identifier",
"start": 616,
"end": 622,
"loc": {
"start": {
"line": 24,
"column": 63
},
"end": {
"line": 24,
"column": 69
},
"identifierName": "stdout"
},
"name": "stdout"
},
"computed": false
},
{
"type": "ArrowFunctionExpression",
"start": 624,
"end": 691,
"loc": {
"start": {
"line": 24,
"column": 71
},
"end": {
"line": 26,
"column": 5
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 624,
"end": 628,
"loc": {
"start": {
"line": 24,
"column": 71
},
"end": {
"line": 24,
"column": 75
},
"identifierName": "line"
},
"name": "line"
}
],
"body": {
"type": "BlockStatement",
"start": 632,
"end": 691,
"loc": {
"start": {