I'm extremely stupid and didn't commit as I go. To anyone reading this
I'm extremely sorry. A lot of these changes are very broad and I plan on
releasing Babel 6.0.0 today live on stage at Ember Camp London so I'm
afraid I couldn't wait. If you're ever in London I'll buy you a beer
(or assorted beverage!) to make up for it, also I'll kiss your feet and
give you a back massage, maybe.
This commit is contained in:
Sebastian McKenzie
2015-10-29 17:51:24 +00:00
parent 3974dd762d
commit ae7d5367f1
1501 changed files with 16477 additions and 19786 deletions

View File

@@ -3,13 +3,13 @@
import { types as tt } from "../tokenizer/types";
import Parser from "../parser";
var pp = Parser.prototype;
let pp = Parser.prototype;
pp.flowParseTypeInitialiser = function (tok) {
var oldInType = this.state.inType;
let oldInType = this.state.inType;
this.state.inType = true;
this.expect(tok || tt.colon);
var type = this.flowParseType();
let type = this.flowParseType();
this.state.inType = oldInType;
return type;
};
@@ -23,10 +23,10 @@ pp.flowParseDeclareClass = function (node) {
pp.flowParseDeclareFunction = function (node) {
this.next();
var id = node.id = this.parseIdentifier();
let id = node.id = this.parseIdentifier();
var typeNode = this.startNode();
var typeContainer = this.startNode();
let typeNode = this.startNode();
let typeContainer = this.startNode();
if (this.isRelational("<")) {
typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -35,7 +35,7 @@ pp.flowParseDeclareFunction = function (node) {
}
this.expect(tt.parenL);
var tmp = this.flowParseFunctionTypeParams();
let tmp = this.flowParseFunctionTypeParams();
typeNode.params = tmp.params;
typeNode.rest = tmp.rest;
this.expect(tt.parenR);
@@ -81,11 +81,11 @@ pp.flowParseDeclareModule = function (node) {
node.id = this.parseIdentifier();
}
var bodyNode = node.body = this.startNode();
var body = bodyNode.body = [];
let bodyNode = node.body = this.startNode();
let body = bodyNode.body = [];
this.expect(tt.braceL);
while (!this.match(tt.braceR)) {
var node2 = this.startNode();
let node2 = this.startNode();
// todo: declare check
this.next();
@@ -122,7 +122,7 @@ pp.flowParseInterfaceish = function (node, allowStatic) {
};
pp.flowParseInterfaceExtends = function () {
var node = this.startNode();
let node = this.startNode();
node.id = this.parseIdentifier();
if (this.isRelational("<")) {
@@ -159,7 +159,7 @@ pp.flowParseTypeAlias = function (node) {
// Type annotations
pp.flowParseTypeParameterDeclaration = function () {
var node = this.startNode();
let node = this.startNode();
node.params = [];
this.expectRelational("<");
@@ -175,7 +175,7 @@ pp.flowParseTypeParameterDeclaration = function () {
};
pp.flowParseTypeParameterInstantiation = function () {
var node = this.startNode(), oldInType = this.state.inType;
let node = this.startNode(), oldInType = this.state.inType;
node.params = [];
this.state.inType = true;
@@ -238,7 +238,7 @@ pp.flowParseObjectTypeMethodish = function (node) {
};
pp.flowParseObjectTypeMethod = function (startPos, startLoc, isStatic, key) {
var node = this.startNodeAt(startPos, startLoc);
let node = this.startNodeAt(startPos, startLoc);
node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(startPos, startLoc));
node.static = isStatic;
node.key = key;
@@ -248,7 +248,7 @@ pp.flowParseObjectTypeMethod = function (startPos, startLoc, isStatic, key) {
};
pp.flowParseObjectTypeCallProperty = function (node, isStatic) {
var valueNode = this.startNode();
let valueNode = this.startNode();
node.static = isStatic;
node.value = this.flowParseObjectTypeMethodish(valueNode);
this.flowObjectTypeSemicolon();
@@ -256,10 +256,10 @@ pp.flowParseObjectTypeCallProperty = function (node, isStatic) {
};
pp.flowParseObjectType = function (allowStatic) {
var nodeStart = this.startNode();
var node;
var propertyKey;
var isStatic;
let nodeStart = this.startNode();
let node;
let propertyKey;
let isStatic;
nodeStart.callProperties = [];
nodeStart.properties = [];
@@ -268,8 +268,8 @@ pp.flowParseObjectType = function (allowStatic) {
this.expect(tt.braceL);
while (!this.match(tt.braceR)) {
var optional = false;
var startPos = this.state.start, startLoc = this.state.startLoc;
let optional = false;
let startPos = this.state.start, startLoc = this.state.startLoc;
node = this.startNode();
if (allowStatic && this.isContextual("static")) {
this.next();
@@ -315,13 +315,13 @@ pp.flowObjectTypeSemicolon = function () {
};
pp.flowParseGenericType = function (startPos, startLoc, id) {
var node = this.startNodeAt(startPos, startLoc);
let node = this.startNodeAt(startPos, startLoc);
node.typeParameters = null;
node.id = id;
while (this.eat(tt.dot)) {
var node2 = this.startNodeAt(startPos, startLoc);
let node2 = this.startNodeAt(startPos, startLoc);
node2.qualification = node.id;
node2.id = this.parseIdentifier();
node.id = this.finishNode(node2, "QualifiedTypeIdentifier");
@@ -335,14 +335,14 @@ pp.flowParseGenericType = function (startPos, startLoc, id) {
};
pp.flowParseTypeofType = function () {
var node = this.startNode();
let node = this.startNode();
this.expect(tt._typeof);
node.argument = this.flowParsePrimaryType();
return this.finishNode(node, "TypeofTypeAnnotation");
};
pp.flowParseTupleType = function () {
var node = this.startNode();
let node = this.startNode();
node.types = [];
this.expect(tt.bracketL);
// We allow trailing commas
@@ -356,8 +356,8 @@ pp.flowParseTupleType = function () {
};
pp.flowParseFunctionTypeParam = function () {
var optional = false;
var node = this.startNode();
let optional = false;
let node = this.startNode();
node.name = this.parseIdentifier();
if (this.eat(tt.question)) {
optional = true;
@@ -368,7 +368,7 @@ pp.flowParseFunctionTypeParam = function () {
};
pp.flowParseFunctionTypeParams = function () {
var ret = { params: [], rest: null };
let ret = { params: [], rest: null };
while (this.match(tt.name)) {
ret.params.push(this.flowParseFunctionTypeParam());
if (!this.match(tt.parenR)) {
@@ -411,11 +411,11 @@ pp.flowIdentToTypeAnnotation = function (startPos, startLoc, node, id) {
// primary types are kind of like primary expressions...they're the
// primitives with which other types are constructed.
pp.flowParsePrimaryType = function () {
var startPos = this.state.start, startLoc = this.state.startLoc;
var node = this.startNode();
var tmp;
var type;
var isGroupedType = false;
let startPos = this.state.start, startLoc = this.state.startLoc;
let node = this.startNode();
let tmp;
let type;
let isGroupedType = false;
switch (this.state.type) {
case tt.name:
@@ -449,7 +449,7 @@ pp.flowParsePrimaryType = function () {
// Check to see if this is actually a grouped type
if (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {
if (this.match(tt.name)) {
var token = this.lookahead().type;
let token = this.lookahead().type;
isGroupedType = token !== tt.question && token !== tt.colon;
} else {
isGroupedType = true;
@@ -490,8 +490,9 @@ pp.flowParsePrimaryType = function () {
return this.finishNode(node, "FunctionTypeAnnotation");
case tt.string:
node.rawValue = node.value = this.state.value;
node.raw = this.input.slice(this.state.start, this.state.end);
node.value = this.state.value;
this.addExtra(node, "rawValue", node.value);
this.addExtra(node, "raw", this.input.slice(this.state.start, this.state.end));
this.next();
return this.finishNode(node, "StringLiteralTypeAnnotation");
@@ -501,8 +502,9 @@ pp.flowParsePrimaryType = function () {
return this.finishNode(node, "BooleanLiteralTypeAnnotation");
case tt.num:
node.rawValue = node.value = this.state.value;
node.raw = this.input.slice(this.state.start, this.state.end);
node.value = this.state.value;
this.addExtra(node, "rawValue", node.value);
this.addExtra(node, "raw", this.input.slice(this.state.start, this.state.end));
this.next();
return this.finishNode(node, "NumberLiteralTypeAnnotation");
@@ -516,8 +518,8 @@ pp.flowParsePrimaryType = function () {
};
pp.flowParsePostfixType = function () {
var node = this.startNode();
var type = node.elementType = this.flowParsePrimaryType();
let node = this.startNode();
let type = node.elementType = this.flowParsePrimaryType();
if (this.match(tt.bracketL)) {
this.expect(tt.bracketL);
this.expect(tt.bracketR);
@@ -528,7 +530,7 @@ pp.flowParsePostfixType = function () {
};
pp.flowParsePrefixType = function () {
var node = this.startNode();
let node = this.startNode();
if (this.eat(tt.question)) {
node.typeAnnotation = this.flowParsePrefixType();
return this.finishNode(node, "NullableTypeAnnotation");
@@ -538,8 +540,8 @@ pp.flowParsePrefixType = function () {
};
pp.flowParseIntersectionType = function () {
var node = this.startNode();
var type = this.flowParsePrefixType();
let node = this.startNode();
let type = this.flowParsePrefixType();
node.types = [type];
while (this.eat(tt.bitwiseAND)) {
node.types.push(this.flowParsePrefixType());
@@ -548,8 +550,8 @@ pp.flowParseIntersectionType = function () {
};
pp.flowParseUnionType = function () {
var node = this.startNode();
var type = this.flowParseIntersectionType();
let node = this.startNode();
let type = this.flowParseIntersectionType();
node.types = [type];
while (this.eat(tt.bitwiseOR)) {
node.types.push(this.flowParseIntersectionType());
@@ -558,22 +560,22 @@ pp.flowParseUnionType = function () {
};
pp.flowParseType = function () {
var oldInType = this.state.inType;
let oldInType = this.state.inType;
this.state.inType = true;
var type = this.flowParseUnionType();
let type = this.flowParseUnionType();
this.state.inType = oldInType;
return type;
};
pp.flowParseTypeAnnotation = function () {
var node = this.startNode();
let node = this.startNode();
node.typeAnnotation = this.flowParseTypeInitialiser();
return this.finishNode(node, "TypeAnnotation");
};
pp.flowParseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) {
var ident = this.parseIdentifier();
var isOptionalParam = false;
let ident = this.parseIdentifier();
let isOptionalParam = false;
if (canBeOptionalParam && this.eat(tt.question)) {
this.expect(tt.question);
@@ -612,7 +614,7 @@ export default function (instance) {
return function (declaration, topLevel) {
// strict mode handling of `interface` since it's a reserved word
if (this.state.strict && this.match(tt.name) && this.state.value === "interface") {
var node = this.startNode();
let node = this.startNode();
this.next();
return this.flowParseInterface(node);
} else {
@@ -652,7 +654,7 @@ export default function (instance) {
instance.extend("parseParenItem", function () {
return function (node, startLoc, startPos, forceArrow?) {
if (this.match(tt.colon)) {
var typeCastNode = this.startNodeAt(startLoc, startPos);
let typeCastNode = this.startNodeAt(startLoc, startPos);
typeCastNode.expression = node;
typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
@@ -662,7 +664,7 @@ export default function (instance) {
if (this.eat(tt.arrow)) {
// ((lol): number => {});
var func = this.parseArrowExpression(this.startNodeAt(startLoc, startPos), [node]);
let func = this.parseArrowExpression(this.startNodeAt(startLoc, startPos), [node]);
func.returnType = typeCastNode.typeAnnotation;
return func;
} else {
@@ -689,7 +691,7 @@ export default function (instance) {
if (this.isContextual("type")) {
node.exportKind = "type";
var declarationNode = this.startNode();
let declarationNode = this.startNode();
this.next();
if (this.match(tt.braceL)) {
@@ -754,8 +756,8 @@ export default function (instance) {
// turn type casts that we found in function parameter head into type annotated params
instance.extend("toAssignableList", function (inner) {
return function (exprList, isBinding) {
for (var i = 0; i < exprList.length; i++) {
var expr = exprList[i];
for (let i = 0; i < exprList.length; i++) {
let expr = exprList[i];
if (expr && expr.type === "TypeCastExpression") {
exprList[i] = typeCastToParameter(expr);
}
@@ -768,8 +770,8 @@ export default function (instance) {
// type casts that we've found that are illegal in this context
instance.extend("toReferencedList", function () {
return function (exprList) {
for (var i = 0; i < exprList.length; i++) {
var expr = exprList[i];
for (let i = 0; i < exprList.length; i++) {
let expr = exprList[i];
if (expr && expr._exprListItem && expr.type === "TypeCastExpression") {
this.raise(expr.start, "Unexpected type cast");
}
@@ -783,8 +785,8 @@ export default function (instance) {
// the position where this function is cal;ed
instance.extend("parseExprListItem", function (inner) {
return function (allowEmpty, refShorthandDefaultPos) {
var container = this.startNode();
var node = inner.call(this, allowEmpty, refShorthandDefaultPos);
let container = this.startNode();
let node = inner.call(this, allowEmpty, refShorthandDefaultPos);
if (this.match(tt.colon)) {
container._exprListItem = true;
container.expression = node;
@@ -816,13 +818,11 @@ export default function (instance) {
// parse type parameters for class methods
instance.extend("parseClassMethod", function () {
return function (classBody, method, isGenerator, isAsync) {
var typeParameters;
if (this.isRelational("<")) {
typeParameters = this.flowParseTypeParameterDeclaration();
method.typeParameters = this.flowParseTypeParameterDeclaration();
}
method.value = this.parseMethod(isGenerator, isAsync);
method.value.typeParameters = typeParameters;
classBody.body.push(this.finishNode(method, "MethodDefinition"));
this.parseMethod(method, isGenerator, isAsync);
classBody.body.push(this.finishNode(method, "ClassMethod"));
};
});
@@ -835,7 +835,7 @@ export default function (instance) {
}
if (this.isContextual("implements")) {
this.next();
var implemented = node.implements = [];
let implemented = node.implements = [];
do {
let node = this.startNode();
node.id = this.parseIdentifier();
@@ -853,7 +853,7 @@ export default function (instance) {
// parse type parameters for object method shorthand
instance.extend("parseObjPropValue", function (inner) {
return function (prop) {
var typeParameters;
let typeParameters;
// method shorthand
if (this.isRelational("<")) {
@@ -865,7 +865,7 @@ export default function (instance) {
// add typeParameters if we found them
if (typeParameters) {
prop.value.typeParameters = typeParameters;
(prop.value || prop).typeParameters = typeParameters;
}
};
});
@@ -889,14 +889,14 @@ export default function (instance) {
return function (node) {
node.importKind = "value";
var kind = null;
let kind = null;
if (this.match(tt._typeof)) {
kind = "typeof";
} else if (this.isContextual("type")) {
kind = "type";
}
if (kind) {
var lh = this.lookahead();
let lh = this.lookahead();
if ((lh.type === tt.name && lh.value !== "from") || lh.type === tt.braceL || lh.type === tt.star) {
this.next();
node.importKind = kind;
@@ -917,7 +917,7 @@ export default function (instance) {
};
});
// parse flow type annotations on variable declarator heads - var foo: string = bar
// parse flow type annotations on variable declarator heads - let foo: string = bar
instance.extend("parseVarHead", function (inner) {
return function (decl) {
inner.call(this, decl);
@@ -928,7 +928,7 @@ export default function (instance) {
};
});
// parse the return type of an async arrow function - var foo = (async (): number => {});
// parse the return type of an async arrow function - let foo = (async (): number => {});
instance.extend("parseAsyncArrowFromCallExpression", function (inner) {
return function (node, call) {
if (this.match(tt.colon)) {
@@ -953,7 +953,7 @@ export default function (instance) {
startLoc = startLoc || this.state.startLoc;
if (this.lookahead().type === tt.parenR) {
// var foo = (): number => {};
// let foo = (): number => {};
this.expect(tt.parenL);
this.expect(tt.parenR);
@@ -962,11 +962,11 @@ export default function (instance) {
this.expect(tt.arrow);
return this.parseArrowExpression(node, [], isAsync);
} else {
// var foo = (foo): number => {};
// let foo = (foo): number => {};
let node = inner.call(this, startPos, startLoc, canBeArrow, isAsync);
if (this.match(tt.colon)) {
var state = this.state.clone();
let state = this.state.clone();
try {
return this.parseParenItem(node, startPos, startLoc, true);
} catch (err) {

View File

@@ -26,7 +26,7 @@ tt.jsxTagStart.updateContext = function() {
};
tt.jsxTagEnd.updateContext = function(prevType) {
var out = this.state.context.pop();
let out = this.state.context.pop();
if (out === tc.j_oTag && prevType === tt.slash || out === tc.j_cTag) {
this.state.context.pop();
this.state.exprAllowed = this.curContext() === tc.j_expr;
@@ -35,18 +35,19 @@ tt.jsxTagEnd.updateContext = function(prevType) {
}
};
var pp = Parser.prototype;
let pp = Parser.prototype;
// Reads inline JSX contents token.
pp.jsxReadToken = function() {
var out = "", chunkStart = this.state.pos;
let out = "";
let chunkStart = this.state.pos;
for (;;) {
if (this.state.pos >= this.input.length) {
this.raise(this.state.start, "Unterminated JSX contents");
}
var ch = this.input.charCodeAt(this.state.pos);
let ch = this.input.charCodeAt(this.state.pos);
switch (ch) {
case 60: // "<"
@@ -80,8 +81,8 @@ pp.jsxReadToken = function() {
};
pp.jsxReadNewLine = function(normalizeCRLF) {
var ch = this.input.charCodeAt(this.state.pos);
var out;
let ch = this.input.charCodeAt(this.state.pos);
let out;
++this.state.pos;
if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
++this.state.pos;
@@ -96,13 +97,14 @@ pp.jsxReadNewLine = function(normalizeCRLF) {
};
pp.jsxReadString = function(quote) {
var out = "", chunkStart = ++this.state.pos;
let out = "";
let chunkStart = ++this.state.pos;
for (;;) {
if (this.state.pos >= this.input.length) {
this.raise(this.state.start, "Unterminated string constant");
}
var ch = this.input.charCodeAt(this.state.pos);
let ch = this.input.charCodeAt(this.state.pos);
if (ch === quote) break;
if (ch === 38) { // "&"
out += this.input.slice(chunkStart, this.state.pos);
@@ -121,10 +123,12 @@ pp.jsxReadString = function(quote) {
};
pp.jsxReadEntity = function() {
var str = "", count = 0, entity;
var ch = this.input[this.state.pos];
let str = "";
let count = 0;
let entity;
let ch = this.input[this.state.pos];
var startPos = ++this.state.pos;
let startPos = ++this.state.pos;
while (this.state.pos < this.input.length && count++ < 10) {
ch = this.input[this.state.pos++];
if (ch === ";") {
@@ -161,7 +165,8 @@ pp.jsxReadEntity = function() {
// by isIdentifierStart in readToken.
pp.jsxReadWord = function() {
var ch, start = this.state.pos;
let ch;
let start = this.state.pos;
do {
ch = this.input.charCodeAt(++this.state.pos);
} while (isIdentifierChar(ch) || ch === 45); // "-"
@@ -187,7 +192,7 @@ function getQualifiedJSXName(object) {
// Parse next token as JSX identifier
pp.jsxParseIdentifier = function() {
var node = this.startNode();
let node = this.startNode();
if (this.match(tt.jsxName)) {
node.name = this.state.value;
} else if (this.state.type.keyword) {
@@ -202,11 +207,11 @@ pp.jsxParseIdentifier = function() {
// Parse namespaced identifier.
pp.jsxParseNamespacedName = function() {
var startPos = this.state.start, startLoc = this.state.startLoc;
var name = this.jsxParseIdentifier();
let startPos = this.state.start, startLoc = this.state.startLoc;
let name = this.jsxParseIdentifier();
if (!this.eat(tt.colon)) return name;
var node = this.startNodeAt(startPos, startLoc);
let node = this.startNodeAt(startPos, startLoc);
node.namespace = name;
node.name = this.jsxParseIdentifier();
return this.finishNode(node, "JSXNamespacedName");
@@ -216,10 +221,10 @@ pp.jsxParseNamespacedName = function() {
// or single identifier.
pp.jsxParseElementName = function() {
var startPos = this.state.start, startLoc = this.state.startLoc;
var node = this.jsxParseNamespacedName();
let startPos = this.state.start, startLoc = this.state.startLoc;
let node = this.jsxParseNamespacedName();
while (this.eat(tt.dot)) {
var newNode = this.startNodeAt(startPos, startLoc);
let newNode = this.startNodeAt(startPos, startLoc);
newNode.object = node;
newNode.property = this.jsxParseIdentifier();
node = this.finishNode(newNode, "JSXMemberExpression");
@@ -230,7 +235,7 @@ pp.jsxParseElementName = function() {
// Parses any type of JSX attribute value.
pp.jsxParseAttributeValue = function() {
var node;
let node;
switch (this.state.type) {
case tt.braceL:
node = this.jsxParseExpressionContainer();
@@ -243,7 +248,7 @@ pp.jsxParseAttributeValue = function() {
case tt.jsxTagStart:
case tt.string:
node = this.parseExprAtom();
node.rawValue = null;
node.extra = null;
return node;
default:
@@ -251,27 +256,20 @@ pp.jsxParseAttributeValue = function() {
}
};
// JSXEmptyExpression is unique type since it doesn"t actually parse anything,
// JSXEmptyExpression is unique type since it doesn't actually parse anything,
// and so it should start at the end of last read token (left brace) and finish
// at the beginning of the next one (right brace).
pp.jsxParseEmptyExpression = function() {
var tmp = this.state.start;
this.state.start = this.state.lastTokEnd;
this.state.lastTokEnd = tmp;
tmp = this.state.startLoc;
this.state.startLoc = this.state.lastTokEndLoc;
this.state.lastTokEndLoc = tmp;
return this.finishNode(this.startNode(), "JSXEmptyExpression");
let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
return this.finishNodeAt(node, "JSXEmptyExpression", this.start, this.startLoc);
};
// Parses JSX expression enclosed into curly brackets.
pp.jsxParseExpressionContainer = function() {
var node = this.startNode();
let node = this.startNode();
this.next();
if (this.match(tt.braceR)) {
node.expression = this.jsxParseEmptyExpression();
@@ -285,7 +283,7 @@ pp.jsxParseExpressionContainer = function() {
// Parses following JSX attribute name-value pair.
pp.jsxParseAttribute = function() {
var node = this.startNode();
let node = this.startNode();
if (this.eat(tt.braceL)) {
this.expect(tt.ellipsis);
node.argument = this.parseMaybeAssign();
@@ -300,7 +298,7 @@ pp.jsxParseAttribute = function() {
// Parses JSX opening tag starting after "<".
pp.jsxParseOpeningElementAt = function(startPos, startLoc) {
var node = this.startNodeAt(startPos, startLoc);
let node = this.startNodeAt(startPos, startLoc);
node.attributes = [];
node.name = this.jsxParseElementName();
while (!this.match(tt.slash) && !this.match(tt.jsxTagEnd)) {
@@ -314,7 +312,7 @@ pp.jsxParseOpeningElementAt = function(startPos, startLoc) {
// Parses JSX closing tag starting after "</".
pp.jsxParseClosingElementAt = function(startPos, startLoc) {
var node = this.startNodeAt(startPos, startLoc);
let node = this.startNodeAt(startPos, startLoc);
node.name = this.jsxParseElementName();
this.expect(tt.jsxTagEnd);
return this.finishNode(node, "JSXClosingElement");
@@ -324,10 +322,10 @@ pp.jsxParseClosingElementAt = function(startPos, startLoc) {
// (starting after "<"), attributes, contents and closing tag.
pp.jsxParseElementAt = function(startPos, startLoc) {
var node = this.startNodeAt(startPos, startLoc);
var children = [];
var openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
var closingElement = null;
let node = this.startNodeAt(startPos, startLoc);
let children = [];
let openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
let closingElement = null;
if (!openingElement.selfClosing) {
contents: for (;;) {
@@ -375,7 +373,7 @@ pp.jsxParseElementAt = function(startPos, startLoc) {
// Parses entire JSX element from current position.
pp.jsxParseElement = function() {
var startPos = this.state.start, startLoc = this.state.startLoc;
let startPos = this.state.start, startLoc = this.state.startLoc;
this.next();
return this.jsxParseElementAt(startPos, startLoc);
};
@@ -384,9 +382,9 @@ export default function(instance) {
instance.extend("parseExprAtom", function(inner) {
return function(refShortHandDefaultPos) {
if (this.match(tt.jsxText)) {
var node = this.parseLiteral(this.state.value, "JSXText");
let node = this.parseLiteral(this.state.value, "JSXText");
// https://github.com/babel/babel/issues/2078
node.rawValue = null;
node.extra = null;
return node;
} else if (this.match(tt.jsxTagStart)) {
return this.jsxParseElement();
@@ -398,7 +396,7 @@ export default function(instance) {
instance.extend("readToken", function(inner) {
return function(code) {
var context = this.curContext();
let context = this.curContext();
if (context === tc.j_expr) {
return this.jsxReadToken();
@@ -431,7 +429,7 @@ export default function(instance) {
instance.extend("updateContext", function(inner) {
return function(prevType) {
if (this.match(tt.braceL)) {
var curContext = this.curContext();
let curContext = this.curContext();
if (curContext === tc.j_oTag) {
this.state.context.push(tc.b_expr);
} else if (curContext === tc.j_expr) {