eggtended-js
Version:
A extended version of the Egg programming language from the Eloquent Javascript book.
1,488 lines • 457 kB
JSON
{
"type": "File",
"start": 0,
"end": 2692,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 129,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2692,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 129,
"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": "xRegExp"
},
"name": "xRegExp"
}
}
],
"source": {
"type": "StringLiteral",
"start": 20,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 29
}
},
"extra": {
"rawValue": "xregexp",
"raw": "\"xregexp\""
},
"value": "xregexp"
}
},
{
"type": "Identifier",
"start": 32,
"end": 801,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 45,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 38,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 16
},
"identifierName": "TokenRegex"
},
"name": "TokenRegex"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 49,
"end": 801,
"loc": {
"start": {
"line": 3,
"column": 17
},
"end": {
"line": 45,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 53,
"end": 171,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 7,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 53,
"end": 64,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 13
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 65,
"end": 69,
"loc": {
"start": {
"line": 4,
"column": 14
},
"end": {
"line": 4,
"column": 18
},
"identifierName": "name"
},
"name": "name"
},
{
"type": "Identifier",
"start": 71,
"end": 83,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 32
},
"identifierName": "regexLiteral"
},
"name": "regexLiteral"
},
{
"type": "Identifier",
"start": 85,
"end": 90,
"loc": {
"start": {
"line": 4,
"column": 34
},
"end": {
"line": 4,
"column": 39
},
"identifierName": "flags"
},
"name": "flags"
}
],
"body": {
"type": "BlockStatement",
"start": 92,
"end": 171,
"loc": {
"start": {
"line": 4,
"column": 41
},
"end": {
"line": 7,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 98,
"end": 115,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 21
}
},
"expression": {
"type": "AssignmentExpression",
"start": 98,
"end": 114,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 20
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 98,
"end": 107,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 13
}
},
"object": {
"type": "ThisExpression",
"start": 98,
"end": 102,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 103,
"end": 107,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 13
},
"identifierName": "name"
},
"name": "name"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 110,
"end": 114,
"loc": {
"start": {
"line": 5,
"column": 16
},
"end": {
"line": 5,
"column": 20
},
"identifierName": "name"
},
"name": "name"
}
}
},
{
"type": "ExpressionStatement",
"start": 120,
"end": 167,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 51
}
},
"expression": {
"type": "AssignmentExpression",
"start": 120,
"end": 166,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 50
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 120,
"end": 135,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 120,
"end": 124,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 125,
"end": 135,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 19
},
"identifierName": "expression"
},
"name": "expression"
},
"computed": false
},
"right": {
"type": "CallExpression",
"start": 138,
"end": 166,
"loc": {
"start": {
"line": 6,
"column": 22
},
"end": {
"line": 6,
"column": 50
}
},
"callee": {
"type": "Identifier",
"start": 138,
"end": 145,
"loc": {
"start": {
"line": 6,
"column": 22
},
"end": {
"line": 6,
"column": 29
},
"identifierName": "xRegExp"
},
"name": "xRegExp"
},
"arguments": [
{
"type": "Identifier",
"start": 146,
"end": 158,
"loc": {
"start": {
"line": 6,
"column": 30
},
"end": {
"line": 6,
"column": 42
},
"identifierName": "regexLiteral"
},
"name": "regexLiteral"
},
{
"type": "Identifier",
"start": 160,
"end": 165,
"loc": {
"start": {
"line": 6,
"column": 44
},
"end": {
"line": 6,
"column": 49
},
"identifierName": "flags"
},
"name": "flags"
}
]
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 175,
"end": 234,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 11,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 179,
"end": 188,
"loc": {
"start": {
"line": 9,
"column": 6
},
"end": {
"line": 9,
"column": 15
},
"identifierName": "lastIndex"
},
"name": "lastIndex"
},
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 191,
"end": 234,
"loc": {
"start": {
"line": 9,
"column": 18
},
"end": {
"line": 11,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 197,
"end": 230,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 37
}
},
"argument": {
"type": "MemberExpression",
"start": 204,
"end": 229,
"loc": {
"start": {
"line": 10,
"column": 11
},
"end": {
"line": 10,
"column": 36
}
},
"object": {
"type": "MemberExpression",
"start": 204,
"end": 219,
"loc": {
"start": {
"line": 10,
"column": 11
},
"end": {
"line": 10,
"column": 26
}
},
"object": {
"type": "ThisExpression",
"start": 204,
"end": 208,
"loc": {
"start": {
"line": 10,
"column": 11
},
"end": {
"line": 10,
"column": 15
}
}
},
"property": {
"type": "Identifier",
"start": 209,
"end": 219,
"loc": {
"start": {
"line": 10,
"column": 16
},
"end": {
"line": 10,
"column": 26
},
"identifierName": "expression"
},
"name": "expression"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 220,
"end": 229,
"loc": {
"start": {
"line": 10,
"column": 27
},
"end": {
"line": 10,
"column": 36
},
"identifierName": "lastIndex"
},
"name": "lastIndex"
},
"computed": false
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 238,
"end": 303,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 15,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 242,
"end": 251,
"loc": {
"start": {
"line": 13,
"column": 6
},
"end": {
"line": 13,
"column": 15
},
"identifierName": "lastIndex"
},
"name": "lastIndex"
},
"kind": "set",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 252,
"end": 257,
"loc": {
"start": {
"line": 13,
"column": 16
},
"end": {
"line": 13,
"column": 21
},
"identifierName": "index"
},
"name": "index"
}
],
"body": {
"type": "BlockStatement",
"start": 259,
"end": 303,
"loc": {
"start": {
"line": 13,
"column": 23
},
"end": {
"line": 15,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 265,
"end": 299,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 38
}
},
"expression": {
"type": "AssignmentExpression",
"start": 265,
"end": 298,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 37
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 265,
"end": 290,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 29
}
},
"object": {
"type": "MemberExpression",
"start": 265,
"end": 280,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 265,
"end": 269,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 270,
"end": 280,
"loc": {
"start": {
"line": 14,
"column": 9
},
"end": {
"line": 14,
"column": 19
},
"identifierName": "expression"
},
"name": "expression"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 281,
"end": 290,
"loc": {
"start": {
"line": 14,
"column": 20
},
"end": {
"line": 14,
"column": 29
},
"identifierName": "lastIndex"
},
"name": "lastIndex"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 293,
"end": 298,
"loc": {
"start": {
"line": 14,
"column": 32
},
"end": {
"line": 14,
"column": 37
},
"identifierName": "index"
},
"name": "index"
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 307,
"end": 362,
"loc": {
"start": {
"line": 17,
"column": 2
},
"end": {
"line": 21,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 307,
"end": 312,
"loc": {
"start": {
"line": 17,
"column": 2
},
"end": {
"line": 17,
"column": 7
},
"identifierName": "reset"
},
"name": "reset"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 315,
"end": 362,
"loc": {
"start": {
"line": 17,
"column": 10
},
"end": {
"line": 21,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 321,
"end": 340,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 23
}
},
"expression": {
"type": "AssignmentExpression",
"start": 321,
"end": 339,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 22
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 321,
"end": 335,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 18
}
},
"object": {
"type": "ThisExpression",
"start": 321,
"end": 325,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 326,
"end": 335,
"loc": {
"start": {
"line": 18,
"column": 9
},
"end": {
"line": 18,
"column": 18
},
"identifierName": "lastIndex"
},
"name": "lastIndex"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 338,
"end": 339,
"loc": {
"start": {
"line": 18,
"column": 21
},
"end": {
"line": 18,
"column": 22
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ReturnStatement",
"start": 346,
"end": 358,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 16
}
},
"argument": {
"type": "ThisExpression",
"start": 353,
"end": 357,
"loc": {
"start": {
"line": 20,
"column": 11
},
"end": {
"line": 20,
"column": 15
}
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 366,
"end": 638,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 36,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 366,
"end": 370,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 23,
"column": 6
},
"identifierName": "exec"
},
"name": "exec"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 371,
"end": 378,
"loc": {
"start": {
"line": 23,
"column": 7
},
"end": {
"line": 23,
"column": 14
},
"identifierName": "program"
},
"name": "program"
}
],
"body": {
"type": "BlockStatement",
"start": 380,
"end": 638,
"loc": {
"start": {
"line": 23,
"column": 16
},
"end": {
"line": 36,
"column": 3
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 386,
"end": 428,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 24,
"column": 46
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 390,
"end": 427,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 45
}
},
"id": {
"type": "Identifier",
"start": 390,
"end": 395,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 13
},
"identifierName": "match"
},
"name": "match"
},
"init": {
"type": "CallExpression",
"start": 398,
"end": 427,
"loc": {
"start": {
"line": 24,
"column": 16
},
"end": {
"line": 24,
"column": 45
}
},
"callee": {
"type": "MemberExpression",
"start": 398,
"end": 418,
"loc": {
"start": {
"line": 24,
"column": 16
},
"end": {
"line": 24,
"column": 36
}
},
"object": {
"type": "MemberExpression",
"start": 398,
"end": 413,
"loc": {
"start": {
"line": 24,
"column": 16
},
"end": {
"line": 24,
"column": 31
}
},
"object": {
"type": "ThisExpression",
"start": 398,
"end": 402,
"loc": {
"start": {
"line": 24,
"column": 16
},
"end": {
"line": 24,
"column": 20
}
}
},
"property": {
"type": "Identifier",
"start": 403,
"end": 413,
"loc": {
"start": {
"line": 24,
"column": 21
},
"end": {
"line": 24,
"column": 31
},
"identifierName": "expression"
},
"name": "expression"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 414,
"end": 418,
"loc": {
"start": {
"line": 24,
"column": 32
},
"end": {
"line": 24,
"column": 36
},
"identifierName": "exec"
},
"name": "exec"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 419,
"end": 426,
"loc": {
"start": {
"line": 24,
"column": 37
},
"end": {
"line": 24,
"column": 44
},
"identifierName": "program"
},
"name": "program"
}
]
}
}
],
"kind": "let"
},
{
"type": "IfStatement",
"start": 434,
"end": 616,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 33,
"column": 5
}
},
"test": {
"type": "BinaryExpression",
"start": 438,
"end": 452,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 22
}
},
"left": {
"type": "Identifier",
"start": 438,
"end": 443,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 13
},
"identifierName": "match"
},
"name": "match"
},
"operator": "!==",
"right": {
"type": "NullLiteral",
"start": 448,
"end": 452,
"loc": {
"start": {
"line": 26,
"column": 18
},
"end": {
"line": 26,
"column": 22
}
}
}
},
"consequent": {
"type": "BlockStatement",
"start": 454,
"end": 616,
"loc": {
"start": {
"line": 26,
"column": 24
},
"end": {
"line": 33,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 462,
"end": 610,
"loc": {
"start": {
"line": 27,
"column": 6
},
"end": {
"line": 32,
"column": 8
}
},
"argument": {
"type": "ObjectExpression",
"start": 469,
"end": 609,
"loc": {
"start": {
"line": 27,
"column": 13
},
"end": {
"line": 32,
"column": 7
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 479,
"end": 494,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 23
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 479,
"end": 483,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 12
},
"identifierName": "type"
},
"name": "type"
},
"value": {
"type": "MemberExpression",
"start": 485,
"end": 494,
"loc": {
"start": {
"line": 28,
"column": 14
},
"end": {
"line": 28,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 485,
"end": 489,
"loc": {
"start": {
"line": 28,
"column": 14
},
"end": {
"line": 28,
"column": 18
}
}
},
"property": {
"type": "Identifier",
"start": 490,
"end": 494,
"loc": {
"start": {
"line": 28,
"column": 19
},
"end": {
"line": 28,
"column": 23
},
"identifierName": "name"
},
"name": "name"
},
"computed": false
}
},
{
"type": "ObjectProperty",
"start": 504,
"end": 519,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 23
}
},
"method": false,
"shorthand": false,
"comp