swc/crates/swc_ecma_parser/tests/tsc/grammarAmbiguities.json

664 lines
15 KiB
JSON

{
"type": "Script",
"span": {
"start": 0,
"end": 188,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 9,
"end": 10,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 11,
"end": 17,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 11,
"end": 17,
"ctxt": 0
},
"value": "n",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 12,
"end": 17,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 14,
"end": 17,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 0,
"end": 35,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 19,
"end": 35,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 21,
"end": 33,
"ctxt": 0
},
"argument": {
"type": "NullLiteral",
"span": {
"start": 28,
"end": 32,
"ctxt": 0
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 45,
"end": 46,
"ctxt": 0
},
"value": "g",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 53,
"end": 59,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 53,
"end": 59,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 54,
"end": 59,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 56,
"end": 59,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 36,
"end": 77,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 61,
"end": 77,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 63,
"end": 75,
"ctxt": 0
},
"argument": {
"type": "NullLiteral",
"span": {
"start": 70,
"end": 74,
"ctxt": 0
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 46,
"end": 52,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 47,
"end": 48,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 47,
"end": 48,
"ctxt": 0
},
"value": "A",
"optional": false
},
"constraint": null,
"default": null
},
{
"type": "TsTypeParameter",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"value": "B",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 78,
"end": 93,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 88,
"end": 89,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 90,
"end": 93,
"ctxt": 0
},
"body": []
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 94,
"end": 109,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 104,
"end": 105,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 106,
"end": 109,
"ctxt": 0
},
"body": []
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 110,
"end": 119,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 114,
"end": 115,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 114,
"end": 115,
"ctxt": 0
},
"value": "A",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
},
{
"type": "VariableDeclarator",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"value": "B",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 121,
"end": 135,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 121,
"end": 134,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 121,
"end": 122,
"ctxt": 0
},
"value": "f",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "CallExpression",
"span": {
"start": 123,
"end": 133,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "g",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 131,
"end": 132,
"ctxt": 0
},
"value": 7.0
}
}
],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 124,
"end": 130,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 125,
"end": 126,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 125,
"end": 126,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": null
},
{
"type": "TsTypeReference",
"span": {
"start": 128,
"end": 129,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 128,
"end": 129,
"ctxt": 0
},
"value": "B",
"optional": false
},
"typeParams": null
}
]
}
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 136,
"end": 152,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 136,
"end": 151,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": "f",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 138,
"end": 143,
"ctxt": 0
},
"operator": "<",
"left": {
"type": "Identifier",
"span": {
"start": 138,
"end": 139,
"ctxt": 0
},
"value": "g",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 142,
"end": 143,
"ctxt": 0
},
"value": "A",
"optional": false
}
}
},
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 145,
"end": 150,
"ctxt": 0
},
"operator": ">",
"left": {
"type": "Identifier",
"span": {
"start": 145,
"end": 146,
"ctxt": 0
},
"value": "B",
"optional": false
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 149,
"end": 150,
"ctxt": 0
},
"value": 7.0
}
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 169,
"end": 188,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 169,
"end": 187,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 169,
"end": 170,
"ctxt": 0
},
"value": "f",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 171,
"end": 176,
"ctxt": 0
},
"operator": "<",
"left": {
"type": "Identifier",
"span": {
"start": 171,
"end": 172,
"ctxt": 0
},
"value": "g",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 175,
"end": 176,
"ctxt": 0
},
"value": "A",
"optional": false
}
}
},
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 178,
"end": 186,
"ctxt": 0
},
"operator": ">",
"left": {
"type": "Identifier",
"span": {
"start": 178,
"end": 179,
"ctxt": 0
},
"value": "B",
"optional": false
},
"right": {
"type": "UnaryExpression",
"span": {
"start": 182,
"end": 186,
"ctxt": 0
},
"operator": "+",
"argument": {
"type": "ParenthesisExpression",
"span": {
"start": 183,
"end": 186,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 184,
"end": 185,
"ctxt": 0
},
"value": 7.0
}
}
}
}
}
],
"typeArguments": null
}
}
],
"interpreter": null
}