* add benchmarks * refactor: tokenize template as middle + tail * perf: avoid push tc.brace * refactor: overwrite skipSpace in jsx plugin * transform tl.templateMiddle/Tail * refactor: simplify JSX context tracking * fix flow error * refactor: move JSX context to context.js * fix: ensure comment stack is correctly handled * rename createPositionFromPosition * rename token type and methods * add tokenIsTemplate * refactor: merge babel 7 logic in babel7CompatTokens * fix flow error
216 lines
6.1 KiB
JSON
216 lines
6.1 KiB
JSON
{
|
|
"type": "File",
|
|
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":4}},
|
|
"program": {
|
|
"type": "Program",
|
|
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":4}},
|
|
"sourceType": "script",
|
|
"interpreter": null,
|
|
"body": [
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
|
"expression": {
|
|
"type": "TemplateLiteral",
|
|
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
|
"expressions": [
|
|
{
|
|
"type": "Identifier",
|
|
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"},
|
|
"name": "x"
|
|
},
|
|
{
|
|
"type": "Identifier",
|
|
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"y"},
|
|
"name": "y"
|
|
}
|
|
],
|
|
"quasis": [
|
|
{
|
|
"type": "TemplateElement",
|
|
"start":1,"end":7,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":7}},
|
|
"value": {
|
|
"raw": "before",
|
|
"cooked": "before"
|
|
},
|
|
"tail": false
|
|
},
|
|
{
|
|
"type": "TemplateElement",
|
|
"start":11,"end":17,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":17}},
|
|
"value": {
|
|
"raw": "middle",
|
|
"cooked": "middle"
|
|
},
|
|
"tail": false
|
|
},
|
|
{
|
|
"type": "TemplateElement",
|
|
"start":21,"end":26,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":26}},
|
|
"value": {
|
|
"raw": "after",
|
|
"cooked": "after"
|
|
},
|
|
"tail": true
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":29,"end":33,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":4}},
|
|
"expression": {
|
|
"type": "TemplateLiteral",
|
|
"start":29,"end":32,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":3}},
|
|
"expressions": [],
|
|
"quasis": [
|
|
{
|
|
"type": "TemplateElement",
|
|
"start":30,"end":31,"loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":2}},
|
|
"value": {
|
|
"raw": "x",
|
|
"cooked": "x"
|
|
},
|
|
"tail": true
|
|
}
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"directives": []
|
|
},
|
|
"tokens": [
|
|
{
|
|
"type": {
|
|
"label": "...${",
|
|
"beforeExpr": true,
|
|
"startsExpr": true,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"value": "`before${",
|
|
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": "name",
|
|
"beforeExpr": false,
|
|
"startsExpr": true,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"value": "x",
|
|
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": "...${",
|
|
"beforeExpr": true,
|
|
"startsExpr": true,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"value": "}middle${",
|
|
"start":10,"end":19,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":19}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": "name",
|
|
"beforeExpr": false,
|
|
"startsExpr": true,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"value": "y",
|
|
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": "...`",
|
|
"beforeExpr": false,
|
|
"startsExpr": true,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"value": "}after`",
|
|
"start":20,"end":27,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":27}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": ";",
|
|
"beforeExpr": true,
|
|
"startsExpr": false,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": "...`",
|
|
"beforeExpr": false,
|
|
"startsExpr": true,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"value": "`x`",
|
|
"start":29,"end":32,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":3}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": ";",
|
|
"beforeExpr": true,
|
|
"startsExpr": false,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"start":32,"end":33,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":4}}
|
|
},
|
|
{
|
|
"type": {
|
|
"label": "eof",
|
|
"beforeExpr": false,
|
|
"startsExpr": false,
|
|
"rightAssociative": false,
|
|
"isLoop": false,
|
|
"isAssign": false,
|
|
"prefix": false,
|
|
"postfix": false,
|
|
"binop": null
|
|
},
|
|
"start":33,"end":33,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":4}}
|
|
}
|
|
]
|
|
} |