add esprima tests and fix bugs picked up by it

This commit is contained in:
Sebastian McKenzie 2015-08-11 00:59:15 +01:00
parent c318c88050
commit df021c7f23
2091 changed files with 82939 additions and 111 deletions

View File

@ -4,11 +4,6 @@
export const defaultOptions = {
// Source type ("script" or "module") for different semantics
sourceType: "script",
// By default, reserved words are not enforced. Disable
// `allowReserved` to enforce them. When this option has the
// value "never", reserved words and keywords can also not be
// used as property names.
allowReserved: true,
// When enabled, a return at the top level is not considered an
// error.
allowReturnOutsideFunction: false,

View File

@ -229,7 +229,7 @@ pp.parseSubscripts = function(base, startPos, startLoc, noCalls) {
} else if (this.eat(tt.dot)) {
let node = this.startNodeAt(startPos, startLoc);
node.object = base;
node.property = this.parseIdent(true);
node.property = this.parseIdentifier(true);
node.computed = false;
base = this.finishNode(node, "MemberExpression");
} else if (this.eat(tt.bracketL)) {
@ -245,10 +245,10 @@ pp.parseSubscripts = function(base, startPos, startLoc, noCalls) {
let node = this.startNodeAt(startPos, startLoc);
node.callee = base;
node.arguments = this.parseExprList(tt.parenR, this.options.features["es7.trailingFunctionCommas"]);
node.arguments = this.parseCallExpressionArguments(tt.parenR, this.options.features["es7.trailingFunctionCommas"], possibleAsync);
base = this.finishNode(node, "CallExpression");
if (possibleAsync && (this.match(tt.colon) || this.match(tt.arrow))) {
if (possibleAsync && this.shouldParseAsyncArrow()) {
base = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node);
} else {
this.toReferencedList(node.arguments);
@ -264,6 +264,38 @@ pp.parseSubscripts = function(base, startPos, startLoc, noCalls) {
}
};
pp.parseCallExpressionArguments = function (close, allowTrailingComma, possibleAsyncArrow) {
let innerParenStart;
let elts = [], first = true;
while (!this.eat(close)) {
if (first) {
first = false;
} else {
this.expect(tt.comma);
if (allowTrailingComma && this.eat(close)) break;
}
// we need to make sure that if this is an async arrow functions, that we don't allow inner parens inside the params
if (this.match(tt.parenL) && !innerParenStart) {
innerParenStart = this.state.start;
}
elts.push(this.parseExprListItem());
}
// we found an async arrow function so let's not allow any inner parens
if (possibleAsyncArrow && innerParenStart && this.shouldParseAsyncArrow()) {
this.unexpected();
}
return elts;
};
pp.shouldParseAsyncArrow = function () {
return this.match(tt.arrow);
};
pp.parseAsyncArrowFromCallExpression = function (node, call) {
if (!this.options.features["es7.asyncFunctions"]) this.unexpected();
this.expect(tt.arrow);
@ -286,16 +318,51 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
let node, canBeArrow = this.state.potentialArrowAt === this.state.start;
switch (this.state.type) {
case tt._super:
if (!this.state.inFunction)
if (!this.state.inFunction) {
this.raise(this.state.start, "'super' outside of function or class");
case tt._this:
let type = this.match(tt._this) ? "ThisExpression" : "Super";
}
node = this.startNode();
this.next();
return this.finishNode(node, type);
if (!this.match(tt.parenL) && !this.match(tt.bracketL) && !this.match(tt.dot)) {
this.unexpected();
}
return this.finishNode(node, "Super");
case tt._this:
node = this.startNode();
this.next();
return this.finishNode(node, "ThisExpression");
case tt._yield:
if (this.state.inGenerator) this.unexpected();
// NOTE: falls through to _let
if (!this.state.inGenerator && this.strict) this.unexpected();
case tt._let:
case tt.name:
node = this.startNode();
let id = this.parseIdentifier(true);
if (this.options.features["es7.asyncFunctions"]) {
if (id.name === "await") {
if (this.inAsync) return this.parseAwait(node);
} else if (id.name === "async" && this.match(tt._function) && !this.canInsertSemicolon()) {
this.next();
return this.parseFunction(node, false, false, true);
} else if (canBeArrow && id.name === "async" && this.match(tt.name)) {
var params = [this.parseIdentifier()];
this.expect(tt.arrow);
// var foo = bar => {};
return this.parseArrowExpression(node, params, true);
}
}
if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
return this.parseArrowExpression(node, [id]);
}
return id;
case tt._do:
if (this.options.features["es7.doExpressions"]) {
@ -311,30 +378,6 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
return this.finishNode(node, "DoExpression");
}
case tt.name:
node = this.startNode();
let id = this.parseIdent(true);
if (this.options.features["es7.asyncFunctions"]) {
if (id.name === "await") {
if (this.inAsync) return this.parseAwait(node);
} else if (id.name === "async" && this.match(tt._function) && !this.canInsertSemicolon()) {
this.next();
return this.parseFunction(node, false, false, true);
} else if (canBeArrow && id.name === "async" && this.match(tt.name)) {
var params = [this.parseIdent()];
this.expect(tt.arrow);
// var foo = bar => {};
return this.parseArrowExpression(node, params, true);
}
}
if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
return this.parseArrowExpression(node, [id]);
}
return id;
case tt.regexp:
let value = this.state.value;
node = this.parseLiteral(value.value);
@ -430,7 +473,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
let innerStartPos = this.state.start, innerStartLoc = this.state.startLoc;
let exprList = [], first = true;
let refShorthandDefaultPos = {start: 0}, spreadStart, innerParenStart, optionalCommaStart;
let refShorthandDefaultPos = { start: 0 }, spreadStart, innerParenStart, optionalCommaStart;
while (!this.match(tt.parenR)) {
if (first) {
first = false;
@ -454,6 +497,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));
}
}
let innerEndPos = this.state.start;
let innerEndLoc = this.state.startLoc;
this.expect(tt.parenR);
@ -497,11 +541,11 @@ pp.parseParenItem = function (node) {
pp.parseNew = function () {
let node = this.startNode();
let meta = this.parseIdent(true);
let meta = this.parseIdentifier(true);
if (this.eat(tt.dot)) {
node.meta = meta;
node.property = this.parseIdent(true);
node.property = this.parseIdentifier(true);
if (node.property.name !== "target") {
this.raise(node.property.start, "The only valid meta property for new is new.target");
@ -592,7 +636,7 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) {
}
if (!isPattern && this.options.features["es7.asyncFunctions"] && this.isContextual("async")) {
if (isGenerator) this.unexpected();
var asyncId = this.parseIdent();
var asyncId = this.parseIdentifier();
if (this.match(tt.colon) || this.match(tt.parenL) || this.match(tt.braceR)) {
prop.key = asyncId;
} else {
@ -629,22 +673,27 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync,
let paramCount = prop.kind === "get" ? 0 : 1;
if (prop.value.params.length !== paramCount) {
let start = prop.value.start;
if (prop.kind === "get")
if (prop.kind === "get") {
this.raise(start, "getter should have no params");
else
} else {
this.raise(start, "setter should have exactly one param");
}
}
} else if (!prop.computed && prop.key.type === "Identifier") {
prop.kind = "init";
if (isPattern) {
if (this.isKeyword(prop.key.name) ||
(this.strict && (reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name))) ||
(!this.options.allowReserved && this.isReservedWord(prop.key.name)))
this.raise(prop.key.start, "Binding " + prop.key.name);
var illegalBinding = this.isKeyword(prop.key.name);
if (!illegalBinding && this.strict) {
illegalBinding = reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name);
}
if (illegalBinding) {
this.raise(prop.key.start, "Binding " + prop.key.name);
}
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
} else if (this.match(tt.eq) && refShorthandDefaultPos) {
if (!refShorthandDefaultPos.start)
if (!refShorthandDefaultPos.start) {
refShorthandDefaultPos.start = this.state.start;
}
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
} else {
prop.value = prop.key.__clone();
@ -663,7 +712,7 @@ pp.parsePropertyName = function (prop) {
return prop.key;
} else {
prop.computed = false;
return prop.key = (this.match(tt.num) || this.match(tt.string)) ? this.parseExprAtom() : this.parseIdent(true);
return prop.key = (this.match(tt.num) || this.match(tt.string)) ? this.parseExprAtom() : this.parseIdentifier(true);
}
};
@ -723,16 +772,19 @@ pp.parseFunctionBody = function (node, allowExpression) {
// If this is a strict mode function, verify that argument names
// are not repeated, and it does not try to bind the words `eval`
// or `arguments`.
if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {
let nameHash = Object.create(null), oldStrict = this.strict;
this.strict = true;
var checkLVal = this.strict;
// arrow function
if (allowExpression) checkLVal = true;
// normal function
if (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) checkLVal = true;
if (checkLVal) {
let nameHash = Object.create(null);
if (node.id) {
this.checkLVal(node.id, true);
}
for (let param of (node.params: Array)) {
this.checkLVal(param, true, nameHash);
}
this.strict = oldStrict;
}
};
@ -773,19 +825,21 @@ pp.parseExprListItem = function (allowEmpty, refShorthandDefaultPos) {
// when parsing properties), it will also convert keywords into
// identifiers.
pp.parseIdent = function (liberal) {
pp.parseIdentifier = function (liberal) {
let node = this.startNode();
if (this.match(tt.name)) {
if (!liberal &&
((!this.options.allowReserved && this.isReservedWord(this.state.value)) ||
(this.strict && reservedWords.strict(this.state.value))))
if (this.isName()) {
if (!liberal && this.strict && reservedWords.strict(this.state.value)) {
this.raise(this.state.start, "The keyword '" + this.state.value + "' is reserved");
}
node.name = this.state.value;
} else if (liberal && this.state.type.keyword) {
node.name = this.state.type.keyword;
} else {
this.unexpected();
}
this.next();
return this.finishNode(node, "Identifier");
};

View File

@ -92,17 +92,22 @@ pp.parseSpread = function (refShorthandDefaultPos) {
pp.parseRest = function () {
let node = this.startNode();
this.next();
node.argument = this.match(tt.name) || this.match(tt.bracketL) ? this.parseBindingAtom() : this.unexpected();
if (this.isName() || this.match(tt.bracketL)) {
node.argument = this.parseBindingAtom();
} else {
this.unexpected();
}
return this.finishNode(node, "RestElement");
};
// Parses lvalue (assignable) atom.
pp.parseBindingAtom = function () {
switch (this.state.type) {
case tt.name:
return this.parseIdent();
if (this.isName()) {
return this.parseIdentifier(true);
}
switch (this.state.type) {
case tt.bracketL:
let node = this.startNode();
this.next();
@ -163,8 +168,10 @@ pp.parseMaybeDefault = function (startPos, startLoc, left) {
pp.checkLVal = function (expr, isBinding, checkClashes) {
switch (expr.type) {
case "Identifier":
if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name)))
if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) {
this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
}
if (checkClashes) {
if (checkClashes[expr.name]) {
this.raise(expr.start, "Argument name clash in strict mode");
@ -179,7 +186,7 @@ pp.checkLVal = function (expr, isBinding, checkClashes) {
break;
case "ObjectPattern":
for (let prop of (expr.properties: Array)) {
for (let prop of (expr.properties: Array)) {
if (prop.type === "Property") prop = prop.value;
this.checkLVal(prop, isBinding, checkClashes);
}

View File

@ -72,8 +72,27 @@ pp.parseStatement = function (declaration, topLevel) {
case tt._switch: return this.parseSwitchStatement(node);
case tt._throw: return this.parseThrowStatement(node);
case tt._try: return this.parseTryStatement(node);
case tt._let: case tt._const: if (!declaration) this.unexpected(); // NOTE: falls through to _var
case tt._var: return this.parseVarStatement(node, starttype);
case tt._let:
// NOTE: falls through to _const
if (!this.strict) {
let state = this.state.clone();
this.next();
var isBindingAtomStart = this.isName() || this.match(tt.braceL) || this.match(tt.bracketL);
// set back lookahead
this.state = state;
if (!isBindingAtomStart) break;
}
case tt._const:
if (!declaration) this.unexpected(); // NOTE: falls through to _var
case tt._var:
return this.parseVarStatement(node, starttype);
case tt._while: return this.parseWhileStatement(node);
case tt._with: return this.parseWithStatement(node);
case tt.braceL: return this.parseBlock();
@ -92,7 +111,7 @@ pp.parseStatement = function (declaration, topLevel) {
case tt.name:
if (this.options.features["es7.asyncFunctions"] && this.state.value === "async") {
// peek ahead and see if next token is a function
var state = this.state.clone();
let state = this.state.clone();
this.next();
if (this.match(tt._function) && !this.canInsertSemicolon()) {
this.expect(tt._function);
@ -101,20 +120,19 @@ pp.parseStatement = function (declaration, topLevel) {
this.state = state;
}
}
}
// If the statement does not start with a statement keyword or a
// brace, it's an ExpressionStatement or LabeledStatement. We
// simply start parsing an expression, and afterwards, if the
// next token is a colon and the expression was a simple
// Identifier node, we switch to interpreting it as a label.
default:
let maybeName = this.state.value, expr = this.parseExpression();
// If the statement does not start with a statement keyword or a
// brace, it's an ExpressionStatement or LabeledStatement. We
// simply start parsing an expression, and afterwards, if the
// next token is a colon and the expression was a simple
// Identifier node, we switch to interpreting it as a label.
let maybeName = this.state.value, expr = this.parseExpression();
if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) {
return this.parseLabeledStatement(node, maybeName, expr);
} else {
return this.parseExpressionStatement(node, expr);
}
if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) {
return this.parseLabeledStatement(node, maybeName, expr);
} else {
return this.parseExpressionStatement(node, expr);
}
};
@ -158,7 +176,7 @@ pp.parseBreakContinueStatement = function (node, keyword) {
} else if (!this.match(tt.name)) {
this.unexpected();
} else {
node.label = this.parseIdent();
node.label = this.parseIdentifier();
this.semicolon();
}
@ -487,12 +505,12 @@ pp.parseFunction = function (node, isStatement, allowExpressionBody, isAsync, op
this.initFunction(node, isAsync);
node.generator = this.eat(tt.star);
if (isStatement && !optionalId && !this.match(tt.name)) {
if (isStatement && !optionalId && !this.isName()) {
this.unexpected();
}
if (this.match(tt.name)) {
node.id = this.parseIdent();
if (this.isName()) {
node.id = this.parseIdentifier();
}
this.parseFunctionParams(node);
@ -613,7 +631,7 @@ pp.parseClassMethod = function (classBody, method, isGenerator, isAsync) {
pp.parseClassId = function (node, isStatement, optionalId) {
if (this.match(tt.name)) {
node.id = this.parseIdent();
node.id = this.parseIdentifier();
} else {
if (optionalId || !isStatement) {
node.id = null;
@ -636,7 +654,7 @@ pp.parseExport = function (node) {
let specifier = this.startNode();
this.next();
if (this.options.features["es7.exportExtensions"] && this.eatContextual("as")) {
specifier.exported = this.parseIdent();
specifier.exported = this.parseIdentifier();
node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")];
this.parseExportSpecifiersMaybe(node);
this.parseExportFrom(node, true);
@ -646,14 +664,14 @@ pp.parseExport = function (node) {
}
} else if (this.options.features["es7.exportExtensions"] && this.isExportDefaultSpecifier()) {
let specifier = this.startNode();
specifier.exported = this.parseIdent(true);
specifier.exported = this.parseIdentifier(true);
node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
if (this.match(tt.comma) && this.lookahead().type === tt.star) {
this.expect(tt.comma);
let specifier = this.startNode();
this.expect(tt.star);
this.expectContextual("as");
specifier.exported = this.parseIdent();
specifier.exported = this.parseIdentifier();
node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
} else {
this.parseExportSpecifiersMaybe(node);
@ -744,7 +762,10 @@ pp.checkExport = function (node) {
// Parses a comma-separated list of module exports.
pp.parseExportSpecifiers = function () {
let nodes = [], first = true;
let nodes = [];
let first = true;
let needsFrom;
// export { x, y as z } [from '...']
this.expect(tt.braceL);
@ -756,12 +777,20 @@ pp.parseExportSpecifiers = function () {
if (this.eat(tt.braceR)) break;
}
let isDefault = this.match(tt._default);
if (isDefault && !needsFrom) needsFrom = true;
let node = this.startNode();
node.local = this.parseIdent(this.match(tt._default));
node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local.__clone();
node.local = this.parseIdentifier(isDefault);
node.exported = this.eatContextual("as") ? this.parseIdentifier(true) : node.local.__clone();
nodes.push(this.finishNode(node, "ExportSpecifier"));
}
// https://github.com/ember-cli/ember-cli/pull/3739
if (needsFrom && !this.isContextual("from")) {
this.unexpected();
}
return nodes;
};
@ -791,7 +820,7 @@ pp.parseImportSpecifiers = function (node) {
if (this.match(tt.name)) {
// import defaultObj, { x, y as z } from '...'
var startPos = this.state.start, startLoc = this.state.startLoc;
node.specifiers.push(this.parseImportSpecifierDefault(this.parseIdent(), startPos, startLoc));
node.specifiers.push(this.parseImportSpecifierDefault(this.parseIdentifier(), startPos, startLoc));
if (!this.eat(tt.comma)) return;
}
@ -799,7 +828,7 @@ pp.parseImportSpecifiers = function (node) {
let specifier = this.startNode();
this.next();
this.expectContextual("as");
specifier.local = this.parseIdent();
specifier.local = this.parseIdentifier();
this.checkLVal(specifier.local, true);
node.specifiers.push(this.finishNode(specifier, "ImportNamespaceSpecifier"));
return;
@ -815,8 +844,8 @@ pp.parseImportSpecifiers = function (node) {
}
let specifier = this.startNode();
specifier.imported = this.parseIdent(true);
specifier.local = this.eatContextual("as") ? this.parseIdent() : specifier.imported.__clone();
specifier.imported = this.parseIdentifier(true);
specifier.local = this.eatContextual("as") ? this.parseIdentifier() : specifier.imported.__clone();
this.checkLVal(specifier.local, true);
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
}

View File

@ -28,6 +28,23 @@ pp.expectRelational = function (op) {
}
};
// TODO
pp.isName = function () {
if (this.match(tt.name)) {
return true;
} else if (!this.strict) {
var keyword = this.state.type.keyword;
if (keyword === "let") {
return true;
} else if (keyword === "yield") {
return !this.state.inGenerator;
}
}
return false;
};
// Tests whether parsed token is a contextual keyword.
pp.isContextual = function (name) {

View File

@ -21,7 +21,7 @@ pp.flowParseDeclareClass = function (node) {
pp.flowParseDeclareFunction = function (node) {
this.next();
var id = node.id = this.parseIdent();
var id = node.id = this.parseIdentifier();
var typeNode = this.startNode();
var typeContainer = this.startNode();
@ -76,7 +76,7 @@ pp.flowParseDeclareModule = function (node) {
if (this.match(tt.string)) {
node.id = this.parseExprAtom();
} else {
node.id = this.parseIdent();
node.id = this.parseIdentifier();
}
var bodyNode = node.body = this.startNode();
@ -100,7 +100,7 @@ pp.flowParseDeclareModule = function (node) {
// Interfaces
pp.flowParseInterfaceish = function (node, allowStatic) {
node.id = this.parseIdent();
node.id = this.parseIdentifier();
if (this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterDeclaration();
@ -122,7 +122,7 @@ pp.flowParseInterfaceish = function (node, allowStatic) {
pp.flowParseInterfaceExtends = function () {
var node = this.startNode();
node.id = this.parseIdent();
node.id = this.parseIdentifier();
if (this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterInstantiation();
} else {
@ -140,7 +140,7 @@ pp.flowParseInterface = function (node) {
// Type aliases
pp.flowParseTypeAlias = function (node) {
node.id = this.parseIdent();
node.id = this.parseIdentifier();
if (this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterDeclaration();
@ -193,7 +193,7 @@ pp.flowParseTypeParameterInstantiation = function () {
};
pp.flowParseObjectPropertyKey = function () {
return (this.match(tt.num) || this.match(tt.string)) ? this.parseExprAtom() : this.parseIdent(true);
return (this.match(tt.num) || this.match(tt.string)) ? this.parseExprAtom() : this.parseIdentifier(true);
};
pp.flowParseObjectTypeIndexer = function (node, isStatic) {
@ -280,7 +280,7 @@ pp.flowParseObjectType = function (allowStatic) {
nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, allowStatic));
} else {
if (isStatic && this.match(tt.colon)) {
propertyKey = this.parseIdent();
propertyKey = this.parseIdentifier();
} else {
propertyKey = this.flowParseObjectPropertyKey();
}
@ -321,7 +321,7 @@ pp.flowParseGenericType = function (startPos, startLoc, id) {
while (this.eat(tt.dot)) {
var node2 = this.startNodeAt(startPos, startLoc);
node2.qualification = node.id;
node2.id = this.parseIdent();
node2.id = this.parseIdentifier();
node.id = this.finishNode(node2, "QualifiedTypeIdentifier");
}
@ -356,7 +356,7 @@ pp.flowParseTupleType = function () {
pp.flowParseFunctionTypeParam = function () {
var optional = false;
var node = this.startNode();
node.name = this.parseIdent();
node.name = this.parseIdentifier();
if (this.eat(tt.question)) {
optional = true;
}
@ -417,7 +417,7 @@ pp.flowParsePrimaryType = function () {
switch (this.state.type) {
case tt.name:
return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdent());
return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdentifier());
case tt.braceL:
return this.flowParseObjectType();
@ -570,7 +570,7 @@ pp.flowParseTypeAnnotation = function () {
};
pp.flowParseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) {
var ident = this.parseIdent();
var ident = this.parseIdentifier();
var isOptionalParam = false;
if (canBeOptionalParam && this.eat(tt.question)) {
@ -592,7 +592,7 @@ pp.flowParseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOp
};
export default function (instance) {
// function name(): string {}
// plain function return types: function name(): string {}
instance.extend("parseFunctionBody", function (inner) {
return function (node, allowExpression) {
if (this.match(tt.colon) && !allowExpression) {
@ -605,6 +605,7 @@ export default function (instance) {
};
});
// interfaces
instance.extend("parseStatement", function (inner) {
return function (declaration, topLevel) {
// strict mode handling of `interface` since it's a reserved word
@ -618,6 +619,7 @@ export default function (instance) {
};
});
// declares, interfaces and type aliases
instance.extend("parseExpressionStatement", function (inner) {
return function (node, expr) {
if (expr.type === "Identifier") {
@ -638,6 +640,7 @@ export default function (instance) {
};
});
// export type
instance.extend("shouldParseExportDeclaration", function (inner) {
return function () {
return this.isContextual("type") || inner.call(this);
@ -723,6 +726,7 @@ export default function (instance) {
};
});
// ensure that inside flow types, we bypass the jsx parser plugin
instance.extend("readToken", function (inner) {
return function (code) {
if (this.state.inType && (code === 62 || code === 60)) {
@ -733,6 +737,7 @@ export default function (instance) {
};
});
// don't lex any token as a jsx one inside a flow type
instance.extend("jsx_readToken", function (inner) {
return function () {
if (!this.state.inType) return inner.call(this);
@ -744,6 +749,7 @@ export default function (instance) {
return node.expression;
}
// 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++) {
@ -756,6 +762,8 @@ export default function (instance) {
};
});
// this is a list of nodes, from something like a call expression, we need to filter the
// 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++) {
@ -769,6 +777,8 @@ export default function (instance) {
};
});
// parse an item inside a expression list eg. `(NODE, NODE)` where NODE represents
// the position where this function is cal;ed
instance.extend("parseExprListItem", function (inner) {
return function (allowEmpty, refShorthandDefaultPos) {
var container = this.startNode();
@ -784,6 +794,7 @@ export default function (instance) {
};
});
// parse class property type annotations
instance.extend("parseClassProperty", function (inner) {
return function (node) {
if (this.match(tt.colon)) {
@ -793,12 +804,14 @@ export default function (instance) {
};
});
// determine whether or not we're currently in the position where a class property would appear
instance.extend("isClassProperty", function (inner) {
return function () {
return this.match(tt.colon) || inner.call(this);
};
});
// parse type parameters for class methods
instance.extend("parseClassMethod", function () {
return function (classBody, method, isGenerator, isAsync) {
var typeParameters;
@ -811,6 +824,7 @@ export default function (instance) {
};
});
// parse a the super class type parameters and implements
instance.extend("parseClassSuper", function (inner) {
return function (node, isStatement) {
inner.call(this, node, isStatement);
@ -822,7 +836,7 @@ export default function (instance) {
var implemented = node.implements = [];
do {
let node = this.startNode();
node.id = this.parseIdent();
node.id = this.parseIdentifier();
if (this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterInstantiation();
} else {
@ -834,6 +848,7 @@ export default function (instance) {
};
});
// parse type parameters for object method shorthand
instance.extend("parseObjPropValue", function (inner) {
return function (prop) {
var typeParameters;
@ -866,11 +881,18 @@ export default function (instance) {
};
});
// parse typeof and type imports
instance.extend("parseImportSpecifiers", function (inner) {
return function (node) {
node.importKind = "value";
var kind = (this.match(tt._typeof) ? "typeof" : (this.isContextual("type") ? "type" : null));
var kind = null;
if (this.match(tt._typeof)) {
kind = "typeof";
} else if (this.isContextual("type")) {
kind = "type";
}
if (kind) {
var lh = this.lookahead();
if ((lh.type === tt.name && lh.value !== "from") || lh.type === tt.braceL || lh.type === tt.star) {
@ -883,7 +905,7 @@ export default function (instance) {
};
});
// function foo<T>() {}
// parse function type parameters - function foo<T>() {}
instance.extend("parseFunctionParams", function (inner) {
return function (node) {
if (this.isRelational("<")) {
@ -893,7 +915,7 @@ export default function (instance) {
};
});
// var foo: string = bar
// parse flow type annotations on variable declarator heads - var foo: string = bar
instance.extend("parseVarHead", function (inner) {
return function (decl) {
inner.call(this, decl);
@ -904,7 +926,7 @@ export default function (instance) {
};
});
// var foo = (async (): number => {});
// parse the return type of an async arrow function - var foo = (async (): number => {});
instance.extend("parseAsyncArrowFromCallExpression", function (inner) {
return function (node, call) {
if (this.match(tt.colon)) {
@ -915,6 +937,14 @@ export default function (instance) {
};
});
// todo description
instance.extend("shouldParseAsyncArrow", function (inner) {
return function () {
return this.match(tt.colon) || inner.call(this);
};
});
// handle return types for arrow functions
instance.extend("parseParenAndDistinguishExpression", function (inner) {
return function (startPos, startLoc, canBeArrow, isAsync) {
startPos = startPos || this.state.start;

View File

@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
}
},
"name": "eval"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 16,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 32
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 17,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 30
}
},
"expression": {
"type": "Literal",
"start": 17,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 29
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"program": {
"type": "Program",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 18
}
},
"name": "arguments"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 37
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 22,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 35
}
},
"expression": {
"type": "Literal",
"start": 22,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 34
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,149 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "CallExpression",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"callee": {
"type": "FunctionExpression",
"start": 1,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 14
}
},
"name": "eval"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 33
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 18,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 31
}
},
"expression": {
"type": "Literal",
"start": 18,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 30
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
},
"parenthesizedExpression": true
},
"arguments": []
}
}
]
}
}

View File

@ -0,0 +1,149 @@
{
"type": "File",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"program": {
"type": "Program",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"expression": {
"type": "CallExpression",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"callee": {
"type": "FunctionExpression",
"start": 1,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 38
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 19
}
},
"name": "arguments"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 38
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 23,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "Literal",
"start": 23,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 35
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
},
"parenthesizedExpression": true
},
"arguments": []
}
}
]
}
}

View File

@ -0,0 +1,149 @@
{
"type": "File",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"program": {
"type": "Program",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"expression": {
"type": "CallExpression",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"callee": {
"type": "FunctionExpression",
"start": 1,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 36
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 17
}
},
"name": "package"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 36
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 21,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 34
}
},
"expression": {
"type": "Literal",
"start": 21,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 33
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
},
"parenthesizedExpression": true
},
"arguments": []
}
}
]
}
}

View File

@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"name": "hello"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 19
}
},
"name": "eval"
}
],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 36
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 22,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 35
}
},
"expression": {
"type": "Literal",
"start": 22,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 34
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"program": {
"type": "Program",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 41
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"name": "hello"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 24
}
},
"name": "arguments"
}
],
"body": {
"type": "BlockStatement",
"start": 26,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 41
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 27,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 40
}
},
"expression": {
"type": "Literal",
"start": 27,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 39
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"name": "hello"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 21
}
},
"name": "static"
}
],
"body": {
"type": "BlockStatement",
"start": 23,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 40
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 38
}
},
"expression": {
"type": "Literal",
"start": 25,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 37
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 15
}
},
"name": "static"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 35
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 20,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 33
}
},
"expression": {
"type": "Literal",
"start": 20,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 32
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "a"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 11,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 15
}
},
"name": "eval"
}
],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 34
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 32
}
},
"expression": {
"type": "Literal",
"start": 19,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 31
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"program": {
"type": "Program",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "a"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 11,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 18
}
},
"name": "package"
}
],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 37
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 22,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 35
}
},
"expression": {
"type": "Literal",
"start": 22,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 34
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,150 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 35
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
},
"name": "a"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 16
}
},
"name": "eval"
}
],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 35
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 20,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 33
}
},
"expression": {
"type": "Literal",
"start": 20,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 32
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
},
"parenthesizedExpression": true
}
}
]
}
}

View File

@ -0,0 +1,150 @@
{
"type": "File",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"program": {
"type": "Program",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 39
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 38
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
},
"name": "a"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 19
}
},
"name": "package"
}
],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 38
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 23,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "Literal",
"start": 23,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 35
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
},
"parenthesizedExpression": true
}
}
]
}
}

View File

@ -0,0 +1,83 @@
{
"type": "File",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"name": "a"
},
"init": null
}
],
"kind": "var"
}
]
}
}

21
test/fixtures/esprima/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,2 @@
{ x
++y }

View File

@ -0,0 +1,129 @@
{
"type": "File",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"program": {
"type": "Program",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 2,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 3
}
},
"expression": {
"type": "Identifier",
"start": 2,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 3
}
},
"name": "x"
}
},
{
"type": "ExpressionStatement",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"expression": {
"type": "UpdateExpression",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"operator": "++",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
}
},
"name": "y"
}
}
}
]
}
]
}
}

View File

@ -0,0 +1,2 @@
{ x
--y }

View File

@ -0,0 +1,129 @@
{
"type": "File",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"program": {
"type": "Program",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 2,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 3
}
},
"expression": {
"type": "Identifier",
"start": 2,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 3
}
},
"name": "x"
}
},
{
"type": "ExpressionStatement",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"expression": {
"type": "UpdateExpression",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"operator": "--",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
}
},
"name": "y"
}
}
}
]
}
]
}
}

View File

@ -0,0 +1 @@
var x /* comment */;

View File

@ -0,0 +1,129 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"name": "x",
"leadingComments": null,
"trailingComments": null
},
"init": null,
"trailingComments": [
{
"type": "CommentBlock",
"value": " comment ",
"start": 6,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 19
}
},
"range": [
6,
19
]
}
]
}
],
"kind": "var"
}
]
},
"comments": [
{
"type": "CommentBlock",
"value": " comment ",
"start": 6,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 19
}
},
"range": [
6,
19
]
}
]
}

View File

@ -0,0 +1,2 @@
{ var x = 14, y = 3
z; }

View File

@ -0,0 +1,197 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 4
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 4
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 4
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 2,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 19
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
}
},
"value": 14,
"rawValue": 14,
"raw": "14"
}
},
{
"type": "VariableDeclarator",
"start": 14,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
},
"name": "y"
},
"init": {
"type": "Literal",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
},
"value": 3,
"rawValue": 3,
"raw": "3"
}
}
],
"kind": "var"
},
{
"type": "ExpressionStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 2
}
},
"expression": {
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
}
},
"name": "z"
}
}
]
}
]
}
}

View File

@ -0,0 +1,2 @@
while (true) { continue
there; }

View File

@ -0,0 +1,130 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "WhileStatement",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"test": {
"type": "Literal",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true,
"rawValue": true,
"raw": "true"
},
"body": {
"type": "BlockStatement",
"start": 13,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 8
}
},
"body": [
{
"type": "ContinueStatement",
"start": 15,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 23
}
},
"label": null
},
{
"type": "ExpressionStatement",
"start": 24,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"expression": {
"type": "Identifier",
"start": 24,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"name": "there"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,2 @@
while (true) { continue // Comment
there; }

View File

@ -0,0 +1,198 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "WhileStatement",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"test": {
"type": "Literal",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true,
"rawValue": true,
"raw": "true"
},
"body": {
"type": "BlockStatement",
"start": 13,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 8
}
},
"body": [
{
"type": "ContinueStatement",
"start": 15,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 23
}
},
"label": null,
"leadingComments": null,
"trailingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 24,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 34
}
},
"range": [
24,
34
]
}
]
},
{
"type": "ExpressionStatement",
"start": 35,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"expression": {
"type": "Identifier",
"start": 35,
"end": 40,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"name": "there",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 24,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 34
}
},
"range": [
24,
34
]
}
]
}
]
}
}
]
},
"comments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 24,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 34
}
},
"range": [
24,
34
]
}
]
}

View File

@ -0,0 +1,2 @@
while (true) { continue /* Multiline
Comment */there; }

View File

@ -0,0 +1,198 @@
{
"type": "File",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"sourceType": "script",
"body": [
{
"type": "WhileStatement",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"test": {
"type": "Literal",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true,
"rawValue": true,
"raw": "true"
},
"body": {
"type": "BlockStatement",
"start": 13,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 18
}
},
"body": [
{
"type": "ContinueStatement",
"start": 15,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 23
}
},
"label": null,
"leadingComments": null,
"trailingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 24,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
24,
47
]
}
]
},
{
"type": "ExpressionStatement",
"start": 47,
"end": 53,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 16
}
},
"expression": {
"type": "Identifier",
"start": 47,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 15
}
},
"name": "there",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 24,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
24,
47
]
}
]
}
]
}
}
]
},
"comments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 24,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
24,
47
]
}
]
}

View File

@ -0,0 +1,2 @@
while (true) { break
there; }

View File

@ -0,0 +1,130 @@
{
"type": "File",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "WhileStatement",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"test": {
"type": "Literal",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true,
"rawValue": true,
"raw": "true"
},
"body": {
"type": "BlockStatement",
"start": 13,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 8
}
},
"body": [
{
"type": "BreakStatement",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"label": null
},
{
"type": "ExpressionStatement",
"start": 21,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"expression": {
"type": "Identifier",
"start": 21,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"name": "there"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1,2 @@
while (true) { break // Comment
there; }

View File

@ -0,0 +1,198 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "WhileStatement",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"test": {
"type": "Literal",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true,
"rawValue": true,
"raw": "true"
},
"body": {
"type": "BlockStatement",
"start": 13,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 8
}
},
"body": [
{
"type": "BreakStatement",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"label": null,
"leadingComments": null,
"trailingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 21,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 31
}
},
"range": [
21,
31
]
}
]
},
{
"type": "ExpressionStatement",
"start": 32,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"expression": {
"type": "Identifier",
"start": 32,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"name": "there",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 21,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 31
}
},
"range": [
21,
31
]
}
]
}
]
}
}
]
},
"comments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 21,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 31
}
},
"range": [
21,
31
]
}
]
}

View File

@ -0,0 +1,2 @@
while (true) { break /* Multiline
Comment */there; }

View File

@ -0,0 +1,198 @@
{
"type": "File",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"sourceType": "script",
"body": [
{
"type": "WhileStatement",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"test": {
"type": "Literal",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true,
"rawValue": true,
"raw": "true"
},
"body": {
"type": "BlockStatement",
"start": 13,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 18
}
},
"body": [
{
"type": "BreakStatement",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"label": null,
"leadingComments": null,
"trailingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 21,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
21,
44
]
}
]
},
{
"type": "ExpressionStatement",
"start": 44,
"end": 50,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 16
}
},
"expression": {
"type": "Identifier",
"start": 44,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 15
}
},
"name": "there",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 21,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
21,
44
]
}
]
}
]
}
}
]
},
"comments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 21,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
21,
44
]
}
]
}

View File

@ -0,0 +1,2 @@
(function(){ return
x; })

View File

@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 2,
"column": 4
}
},
"id": null,
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 11,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 2,
"column": 4
}
},
"body": [
{
"type": "ReturnStatement",
"start": 13,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 19
}
},
"argument": null
},
{
"type": "ExpressionStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 2
}
},
"expression": {
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
}
},
"name": "x"
}
}
]
},
"parenthesizedExpression": true
}
}
]
}
}

View File

@ -0,0 +1,2 @@
(function(){ return // Comment
x; })

View File

@ -0,0 +1,200 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 2,
"column": 4
}
},
"id": null,
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 11,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 2,
"column": 4
}
},
"body": [
{
"type": "ReturnStatement",
"start": 13,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 19
}
},
"argument": null,
"leadingComments": null,
"trailingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 20,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 30
}
},
"range": [
20,
30
]
}
]
},
{
"type": "ExpressionStatement",
"start": 31,
"end": 33,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 2
}
},
"expression": {
"type": "Identifier",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
}
},
"name": "x",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 20,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 30
}
},
"range": [
20,
30
]
}
]
}
]
},
"parenthesizedExpression": true
}
}
]
},
"comments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 20,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 30
}
},
"range": [
20,
30
]
}
]
}

View File

@ -0,0 +1,2 @@
(function(){ return/* Multiline
Comment */x; })

View File

@ -0,0 +1,200 @@
{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 2,
"column": 14
}
},
"id": null,
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 11,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 2,
"column": 14
}
},
"body": [
{
"type": "ReturnStatement",
"start": 13,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 19
}
},
"argument": null,
"leadingComments": null,
"trailingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 19,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
19,
42
]
}
]
},
{
"type": "ExpressionStatement",
"start": 42,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 12
}
},
"expression": {
"type": "Identifier",
"start": 42,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
}
},
"name": "x",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 19,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
19,
42
]
}
]
}
]
},
"parenthesizedExpression": true
}
}
]
},
"comments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 19,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
19,
42
]
}
]
}

View File

@ -0,0 +1,2 @@
{ throw error
error; }

View File

@ -0,0 +1,112 @@
{
"type": "File",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"body": [
{
"type": "ThrowStatement",
"start": 2,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 13
}
},
"argument": {
"type": "Identifier",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
}
},
"name": "error"
}
},
{
"type": "ExpressionStatement",
"start": 14,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"expression": {
"type": "Identifier",
"start": 14,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"name": "error"
}
}
]
}
]
}
}

View File

@ -0,0 +1,2 @@
{ throw error// Comment
error; }

View File

@ -0,0 +1,181 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"body": [
{
"type": "ThrowStatement",
"start": 2,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 13
}
},
"argument": {
"type": "Identifier",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
}
},
"name": "error",
"leadingComments": null,
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 13,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 23
}
},
"range": [
13,
23
]
}
]
},
{
"type": "ExpressionStatement",
"start": 24,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"expression": {
"type": "Identifier",
"start": 24,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"name": "error",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 13,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 23
}
},
"range": [
13,
23
]
}
]
}
]
}
]
},
"comments": [
{
"type": "CommentLine",
"value": " Comment",
"start": 13,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 23
}
},
"range": [
13,
23
]
}
]
}

View File

@ -0,0 +1,2 @@
{ throw error/* Multiline
Comment */error; }

View File

@ -0,0 +1,181 @@
{
"type": "File",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"body": [
{
"type": "ThrowStatement",
"start": 2,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 13
}
},
"argument": {
"type": "Identifier",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
}
},
"name": "error",
"leadingComments": null,
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 13,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
13,
36
]
}
]
},
{
"type": "ExpressionStatement",
"start": 36,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 16
}
},
"expression": {
"type": "Identifier",
"start": 36,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 15
}
},
"name": "error",
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 13,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
13,
36
]
}
]
}
]
}
]
},
"comments": [
{
"type": "CommentBlock",
"value": " Multiline\nComment ",
"start": 13,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 2,
"column": 10
}
},
"range": [
13,
36
]
}
]
}

View File

@ -0,0 +1 @@
const x = 42

View File

@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
}
},
"value": 42,
"rawValue": 42,
"raw": "42"
}
}
],
"kind": "const"
}
]
}
}

View File

@ -0,0 +1 @@
{ const x = 42 }

View File

@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"program": {
"type": "Program",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 2,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 14
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 8,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 8,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"value": 42,
"rawValue": 42,
"raw": "42"
}
}
],
"kind": "const"
}
]
}
]
}
}

View File

@ -0,0 +1 @@
{ const x = 14, y = 3, z = 1977 }

View File

@ -0,0 +1,215 @@
{
"type": "File",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"program": {
"type": "Program",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 2,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 31
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 8,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 8,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"value": 14,
"rawValue": 14,
"raw": "14"
}
},
{
"type": "VariableDeclarator",
"start": 16,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 21
}
},
"id": {
"type": "Identifier",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 17
}
},
"name": "y"
},
"init": {
"type": "Literal",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"value": 3,
"rawValue": 3,
"raw": "3"
}
},
{
"type": "VariableDeclarator",
"start": 23,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 31
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"name": "z"
},
"init": {
"type": "Literal",
"start": 27,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 31
}
},
"value": 1977,
"rawValue": 1977,
"raw": "1977"
}
}
],
"kind": "const"
}
]
}
]
}
}

View File

@ -0,0 +1 @@
function a(x, x) {'use strict';}

View File

@ -0,0 +1 @@
function a([], []) {'use strict';}

View File

@ -0,0 +1,150 @@
{
"type": "File",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "a"
},
"generator": false,
"expression": false,
"params": [
{
"type": "ArrayPattern",
"start": 11,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 13
}
},
"elements": []
},
{
"type": "ArrayPattern",
"start": 15,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 17
}
},
"elements": []
}
],
"body": {
"type": "BlockStatement",
"start": 19,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 34
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 20,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 33
}
},
"expression": {
"type": "Literal",
"start": 20,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 32
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "'use strict'"
}
}
]
}
}
]
}
}

View File

@ -0,0 +1 @@
function hello() { sayHi(); }

View File

@ -0,0 +1,131 @@
{
"type": "File",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"program": {
"type": "Program",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"name": "hello"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 29
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 27
}
},
"expression": {
"type": "CallExpression",
"start": 19,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 26
}
},
"callee": {
"type": "Identifier",
"start": 19,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 24
}
},
"name": "sayHi"
},
"arguments": []
}
}
]
}
}
]
}
}

View File

@ -0,0 +1 @@
function eval() { }

View File

@ -0,0 +1,83 @@
{
"type": "File",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"program": {
"type": "Program",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
}
},
"name": "eval"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 16,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 19
}
},
"body": []
}
}
]
}
}

View File

@ -0,0 +1 @@
function arguments() { }

View File

@ -0,0 +1,83 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 18
}
},
"name": "arguments"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 24
}
},
"body": []
}
}
]
}
}

View File

@ -0,0 +1 @@
function test(t, t) { }

View File

@ -0,0 +1,116 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
}
},
"name": "test"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
},
"name": "t"
},
{
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
}
},
"name": "t"
}
],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 23
}
},
"body": []
}
}
]
}
}

View File

@ -0,0 +1 @@
(function test(t, t) { })

View File

@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 24
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 14
}
},
"name": "test"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
}
},
"name": "t"
},
{
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
},
"name": "t"
}
],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 24
}
},
"body": []
},
"parenthesizedExpression": true
}
}
]
}
}

View File

@ -0,0 +1 @@
function eval() { function inner() { "use strict" } }

View File

@ -0,0 +1,168 @@
{
"type": "File",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"program": {
"type": "Program",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 53
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
}
},
"name": "eval"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 16,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 53
}
},
"body": [
{
"type": "FunctionDeclaration",
"start": 18,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 51
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 32
}
},
"name": "inner"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 35,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 51
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 37,
"end": 49,
"loc": {
"start": {
"line": 1,
"column": 37
},
"end": {
"line": 1,
"column": 49
}
},
"expression": {
"type": "Literal",
"start": 37,
"end": 49,
"loc": {
"start": {
"line": 1,
"column": 37
},
"end": {
"line": 1,
"column": 49
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
}
]
}
}
]
}
}
]
}
}

View File

@ -0,0 +1 @@
function hello(a) { sayHi(); }

View File

@ -0,0 +1,148 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"name": "hello"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
}
},
"name": "a"
}
],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 30
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 20,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 28
}
},
"expression": {
"type": "CallExpression",
"start": 20,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 27
}
},
"callee": {
"type": "Identifier",
"start": 20,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 25
}
},
"name": "sayHi"
},
"arguments": []
}
}
]
}
}
]
}
}

View File

@ -0,0 +1 @@
function hello(a, b) { sayHi(); }

View File

@ -0,0 +1,164 @@
{
"type": "File",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"program": {
"type": "Program",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"name": "hello"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
}
},
"name": "a"
},
{
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
},
"name": "b"
}
],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 33
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 23,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 31
}
},
"expression": {
"type": "CallExpression",
"start": 23,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 30
}
},
"callee": {
"type": "Identifier",
"start": 23,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 28
}
},
"name": "sayHi"
},
"arguments": []
}
}
]
}
}
]
}
}

View File

@ -0,0 +1 @@
var hi = function() { sayHi() };

View File

@ -0,0 +1,165 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 31
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 6
}
},
"name": "hi"
},
"init": {
"type": "FunctionExpression",
"start": 9,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 31
}
},
"id": null,
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 31
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 29
}
},
"expression": {
"type": "CallExpression",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 29
}
},
"callee": {
"type": "Identifier",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 27
}
},
"name": "sayHi"
},
"arguments": []
}
}
]
}
}
}
],
"kind": "var"
}
]
}
}

View File

@ -0,0 +1 @@
var hi = function eval() { };

View File

@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"program": {
"type": "Program",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 28
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 6
}
},
"name": "hi"
},
"init": {
"type": "FunctionExpression",
"start": 9,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 28
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 22
}
},
"name": "eval"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 25,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 28
}
},
"body": []
}
}
}
],
"kind": "var"
}
]
}
}

View File

@ -0,0 +1 @@
var hi = function arguments() { };

View File

@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 6
}
},
"name": "hi"
},
"init": {
"type": "FunctionExpression",
"start": 9,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 27
}
},
"name": "arguments"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 30,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 30
},
"end": {
"line": 1,
"column": 33
}
},
"body": []
}
}
}
],
"kind": "var"
}
]
}
}

View File

@ -0,0 +1 @@
var hello = function hi() { sayHi() };

View File

@ -0,0 +1,180 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 9
}
},
"name": "hello"
},
"init": {
"type": "FunctionExpression",
"start": 12,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 23
}
},
"name": "hi"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 26,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 37
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 28,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 35
}
},
"expression": {
"type": "CallExpression",
"start": 28,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 35
}
},
"callee": {
"type": "Identifier",
"start": 28,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 33
}
},
"name": "sayHi"
},
"arguments": []
}
}
]
}
}
}
],
"kind": "var"
}
]
}
}

View File

@ -0,0 +1 @@
(function(){})

View File

@ -0,0 +1,84 @@
{
"type": "File",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 13
}
},
"id": null,
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 11,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 13
}
},
"body": []
},
"parenthesizedExpression": true
}
}
]
}
}

View File

@ -0,0 +1 @@
function universe(__proto__) { }

View File

@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 17
}
},
"name": "universe"
},
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 18,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 27
}
},
"name": "__proto__"
}
],
"body": {
"type": "BlockStatement",
"start": 29,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 32
}
},
"body": []
}
}
]
}
}

View File

@ -0,0 +1 @@
function test() { "use strict" + 42; }

View File

@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
}
},
"name": "test"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 16,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 38
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 18,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "BinaryExpression",
"start": 18,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 35
}
},
"left": {
"type": "Literal",
"start": 18,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 30
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
},
"operator": "+",
"right": {
"type": "Literal",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 35
}
},
"value": 42,
"rawValue": 42,
"raw": "42"
}
}
}
]
}
}
]
}
}

View File

@ -0,0 +1 @@
let x

View File

@ -0,0 +1,83 @@
{
"type": "File",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
}
},
"program": {
"type": "Program",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"name": "x"
},
"init": null
}
],
"kind": "let"
}
]
}
}

View File

@ -0,0 +1 @@
{ let x }

View File

@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"program": {
"type": "Program",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 2,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 7
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"name": "x"
},
"init": null
}
],
"kind": "let"
}
]
}
]
}
}

View File

@ -0,0 +1 @@
{ let x = 42 }

View File

@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 2,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 12
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
}
},
"value": 42,
"rawValue": 42,
"raw": "42"
}
}
],
"kind": "let"
}
]
}
]
}
}

View File

@ -0,0 +1 @@
{ let x = 14, y = 3, z = 1977 }

View File

@ -0,0 +1,215 @@
{
"type": "File",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
},
"program": {
"type": "Program",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
},
"sourceType": "script",
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 2,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 29
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
}
},
"value": 14,
"rawValue": 14,
"raw": "14"
}
},
{
"type": "VariableDeclarator",
"start": 14,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
},
"name": "y"
},
"init": {
"type": "Literal",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
},
"value": 3,
"rawValue": 3,
"raw": "3"
}
},
{
"type": "VariableDeclarator",
"start": 21,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 29
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 22
}
},
"name": "z"
},
"init": {
"type": "Literal",
"start": 25,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 29
}
},
"value": 1977,
"rawValue": 1977,
"raw": "1977"
}
}
],
"kind": "let"
}
]
}
]
}
}

Some files were not shown because too many files have changed in this diff Show More