eggtended-js
Version:
A extended version of the Egg programming language from the Eloquent Javascript book.
1,381 lines • 294 kB
JSON
{
"type": "File",
"start": 0,
"end": 688,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 28,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 688,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 28,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 61,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 61
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"imported": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "Value"
},
"name": "Value"
},
"local": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "Value"
},
"name": "Value"
}
},
{
"type": "ImportSpecifier",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
}
},
"imported": {
"type": "Identifier",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "Word"
},
"name": "Word"
},
"local": {
"type": "Identifier",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "Word"
},
"name": "Word"
}
},
{
"type": "ImportSpecifier",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 27
}
},
"imported": {
"type": "Identifier",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 27
},
"identifierName": "Apply"
},
"name": "Apply"
},
"local": {
"type": "Identifier",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 27
},
"identifierName": "Apply"
},
"name": "Apply"
}
},
{
"type": "ImportSpecifier",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 34
}
},
"imported": {
"type": "Identifier",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 34
},
"identifierName": "Regex"
},
"name": "Regex"
},
"local": {
"type": "Identifier",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 34
},
"identifierName": "Regex"
},
"name": "Regex"
}
}
],
"source": {
"type": "StringLiteral",
"start": 42,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 42
},
"end": {
"line": 1,
"column": 60
}
},
"extra": {
"rawValue": "../interp/ast.js",
"raw": "\"../interp/ast.js\""
},
"value": "../interp/ast.js"
}
},
{
"type": "ImportDeclaration",
"start": 62,
"end": 94,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 32
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 69,
"end": 74,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 69,
"end": 74,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "utils"
},
"name": "utils"
}
}
],
"source": {
"type": "StringLiteral",
"start": 80,
"end": 93,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 31
}
},
"extra": {
"rawValue": "../utils.js",
"raw": "\"../utils.js\""
},
"value": "../utils.js"
}
},
{
"type": "Identifier",
"start": 96,
"end": 665,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 25,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 102,
"end": 664,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 25,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 102,
"end": 110,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 14
},
"identifierName": "json2AST"
},
"name": "json2AST"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 113,
"end": 664,
"loc": {
"start": {
"line": 4,
"column": 17
},
"end": {
"line": 25,
"column": 1
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 113,
"end": 117,
"loc": {
"start": {
"line": 4,
"column": 17
},
"end": {
"line": 4,
"column": 21
},
"identifierName": "tree"
},
"name": "tree"
}
],
"body": {
"type": "BlockStatement",
"start": 121,
"end": 664,
"loc": {
"start": {
"line": 4,
"column": 25
},
"end": {
"line": 25,
"column": 1
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 125,
"end": 140,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 17
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 129,
"end": 139,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 129,
"end": 132,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 9
},
"identifierName": "obj"
},
"name": "obj"
},
"init": {
"type": "NullLiteral",
"start": 135,
"end": 139,
"loc": {
"start": {
"line": 5,
"column": 12
},
"end": {
"line": 5,
"column": 16
}
}
}
}
],
"kind": "let"
},
{
"type": "IfStatement",
"start": 144,
"end": 647,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 22,
"column": 3
}
},
"test": {
"type": "BinaryExpression",
"start": 148,
"end": 168,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 26
}
},
"left": {
"type": "MemberExpression",
"start": 148,
"end": 157,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 15
}
},
"object": {
"type": "Identifier",
"start": 148,
"end": 152,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 10
},
"identifierName": "tree"
},
"name": "tree"
},
"property": {
"type": "Identifier",
"start": 153,
"end": 157,
"loc": {
"start": {
"line": 7,
"column": 11
},
"end": {
"line": 7,
"column": 15
},
"identifierName": "type"
},
"name": "type"
},
"computed": false
},
"operator": "==",
"right": {
"type": "StringLiteral",
"start": 161,
"end": 168,
"loc": {
"start": {
"line": 7,
"column": 19
},
"end": {
"line": 7,
"column": 26
}
},
"extra": {
"rawValue": "apply",
"raw": "\"apply\""
},
"value": "apply"
}
},
"consequent": {
"type": "BlockStatement",
"start": 170,
"end": 298,
"loc": {
"start": {
"line": 7,
"column": 28
},
"end": {
"line": 11,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 176,
"end": 198,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 8,
"column": 26
}
},
"expression": {
"type": "AssignmentExpression",
"start": 176,
"end": 197,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 8,
"column": 25
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 176,
"end": 179,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 8,
"column": 7
},
"identifierName": "obj"
},
"name": "obj"
},
"right": {
"type": "NewExpression",
"start": 182,
"end": 197,
"loc": {
"start": {
"line": 8,
"column": 10
},
"end": {
"line": 8,
"column": 25
}
},
"callee": {
"type": "Identifier",
"start": 186,
"end": 191,
"loc": {
"start": {
"line": 8,
"column": 14
},
"end": {
"line": 8,
"column": 19
},
"identifierName": "Apply"
},
"name": "Apply"
},
"arguments": [
{
"type": "Identifier",
"start": 192,
"end": 196,
"loc": {
"start": {
"line": 8,
"column": 20
},
"end": {
"line": 8,
"column": 24
},
"identifierName": "tree"
},
"name": "tree"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 203,
"end": 242,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 43
}
},
"expression": {
"type": "AssignmentExpression",
"start": 203,
"end": 241,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 42
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 203,
"end": 215,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 16
}
},
"object": {
"type": "Identifier",
"start": 203,
"end": 206,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 9,
"column": 7
},
"identifierName": "obj"
},
"name": "obj"
},
"property": {
"type": "Identifier",
"start": 207,
"end": 215,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 16
},
"identifierName": "operator"
},
"name": "operator"
},
"computed": false
},
"right": {
"type": "CallExpression",
"start": 218,
"end": 241,
"loc": {
"start": {
"line": 9,
"column": 19
},
"end": {
"line": 9,
"column": 42
}
},
"callee": {
"type": "Identifier",
"start": 218,
"end": 226,
"loc": {
"start": {
"line": 9,
"column": 19
},
"end": {
"line": 9,
"column": 27
},
"identifierName": "json2AST"
},
"name": "json2AST"
},
"arguments": [
{
"type": "MemberExpression",
"start": 227,
"end": 240,
"loc": {
"start": {
"line": 9,
"column": 28
},
"end": {
"line": 9,
"column": 41
}
},
"object": {
"type": "Identifier",
"start": 227,
"end": 231,
"loc": {
"start": {
"line": 9,
"column": 28
},
"end": {
"line": 9,
"column": 32
},
"identifierName": "tree"
},
"name": "tree"
},
"property": {
"type": "Identifier",
"start": 232,
"end": 240,
"loc": {
"start": {
"line": 9,
"column": 33
},
"end": {
"line": 9,
"column": 41
},
"identifierName": "operator"
},
"name": "operator"
},
"computed": false
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 247,
"end": 294,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 51
}
},
"expression": {
"type": "AssignmentExpression",
"start": 247,
"end": 293,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 50
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 247,
"end": 255,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 12
}
},
"object": {
"type": "Identifier",
"start": 247,
"end": 250,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 7
},
"identifierName": "obj"
},
"name": "obj"
},
"property": {
"type": "Identifier",
"start": 251,
"end": 255,
"loc": {
"start": {
"line": 10,
"column": 8
},
"end": {
"line": 10,
"column": 12
},
"identifierName": "args"
},
"name": "args"
},
"computed": false
},
"right": {
"type": "CallExpression",
"start": 258,
"end": 293,
"loc": {
"start": {
"line": 10,
"column": 15
},
"end": {
"line": 10,
"column": 50
}
},
"callee": {
"type": "MemberExpression",
"start": 258,
"end": 271,
"loc": {
"start": {
"line": 10,
"column": 15
},
"end": {
"line": 10,
"column": 28
}
},
"object": {
"type": "MemberExpression",
"start": 258,
"end": 267,
"loc": {
"start": {
"line": 10,
"column": 15
},
"end": {
"line": 10,
"column": 24
}
},
"object": {
"type": "Identifier",
"start": 258,
"end": 262,
"loc": {
"start": {
"line": 10,
"column": 15
},
"end": {
"line": 10,
"column": 19
},
"identifierName": "tree"
},
"name": "tree"
},
"property": {
"type": "Identifier",
"start": 263,
"end": 267,
"loc": {
"start": {
"line": 10,
"column": 20
},
"end": {
"line": 10,
"column": 24
},
"identifierName": "args"
},
"name": "args"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 268,
"end": 271,
"loc": {
"start": {
"line": 10,
"column": 25
},
"end": {
"line": 10,
"column": 28
},
"identifierName": "map"
},
"name": "map"
},
"computed": false
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 272,
"end": 292,
"loc": {
"start": {
"line": 10,
"column": 29
},
"end": {
"line": 10,
"column": 49
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 272,
"end": 275,
"loc": {
"start": {
"line": 10,
"column": 29
},
"end": {
"line": 10,
"column": 32
},
"identifierName": "arg"
},
"name": "arg"
}
],
"body": {
"type": "CallExpression",
"start": 279,
"end": 292,
"loc": {
"start": {
"line": 10,
"column": 36
},
"end": {
"line": 10,
"column": 49
}
},
"callee": {
"type": "Identifier",
"start": 279,
"end": 287,
"loc": {
"start": {
"line": 10,
"column": 36
},
"end": {
"line": 10,
"column": 44
},
"identifierName": "json2AST"
},
"name": "json2AST"
},
"arguments": [
{
"type": "Identifier",
"start": 288,
"end": 291,
"loc": {
"start": {
"line": 10,
"column": 45
},
"end": {
"line": 10,
"column": 48
},
"identifierName": "arg"
},
"name": "arg"
}
]
}
}
]
}
}
}
],
"directives": []
},
"alternate": {
"type": "IfStatement",
"start": 304,
"end": 647,
"loc": {
"start": {
"line": 11,
"column": 9
},
"end": {
"line": 22,
"column": 3
}
},
"test": {
"type": "BinaryExpression",
"start": 308,
"end": 327,
"loc": {
"start": {
"line": 11,
"column": 13
},
"end": {
"line": 11,
"column": 32
}
},
"left": {
"type": "MemberExpression",
"start": 308,
"end": 317,
"loc": {
"start": {
"line": 11,
"column": 13
},
"end": {
"line": 11,
"column": 22
}
},
"object": {
"type": "Identifier",
"start": 308,
"end": 312,
"loc": {
"start": {
"line": 11,
"column": 13
},
"end": {
"line": 11,
"column": 17
},
"identifierName": "tree"
},
"name": "tree"
},
"property": {
"type": "Identifier",
"start": 313,
"end": 317,
"loc": {
"start": {
"line": 11,
"column": 18
},
"end": {
"line": 11,
"column": 22
},
"identifierName": "type"
},
"name": "type"
},
"computed": false
},
"operator": "==",
"right": {
"type": "StringLiteral",
"start": 321,
"end": 327,
"loc": {
"start": {
"line": 11,
"column": 26
},
"end": {
"line": 11,
"column": 32
}
},
"extra": {
"rawValue": "word",
"raw": "\"word\""
},
"value": "word"
}
},
"consequent": {
"type": "BlockStatement",
"start": 329,
"end": 386,
"loc": {
"start": {
"line": 11,
"column": 34
},
"end": {
"line": 14,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 335,
"end": 356,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 25
}
},
"expression": {
"type": "AssignmentExpression",
"start": 335,
"end": 355,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 24
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 335,
"end": 338,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 7
},
"identifierName": "obj"
},
"name": "obj"
},
"right": {
"type": "NewExpression",
"start": 341,
"end": 355,
"loc": {
"start": {
"line": 12,
"column": 10
},
"end": {
"line": 12,
"column": 24
}
},
"callee": {
"type": "Identifier",
"start": 345,
"end": 349,
"loc": {
"start": {
"line": 12,
"column": 14
},
"end": {
"line": 12,
"column": 18
},
"identifierName": "Word"
},
"name": "Word"
},
"arguments": [
{
"type": "Identifier",
"start": 350,
"end": 354,
"loc": {
"start": {
"line": 12,
"column": 19
},
"end": {
"line": 12,
"column": 23
},
"identifierName": "tree"
},
"name": "tree"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 361,
"end": 382,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 25
}
},
"expression": {
"type": "AssignmentExpression",
"start": 361,
"end": 381,
"loc": {
"start":