Socket
Socket
Sign inDemoInstall

acorn

Package Overview
Dependencies
Maintainers
2
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn - npm Package Compare versions

Comparing version 4.0.3 to 4.0.4

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## 4.0.4 (2016-12-19)
### Bug fixes
Fix issue with loading acorn_loose.js with an AMD loader.
Fix crash when `export` was followed by a keyword that can't be
exported.
## 4.0.3 (2016-08-16)

@@ -2,0 +11,0 @@

33

dist/acorn_loose.es.js

@@ -1,2 +0,2 @@

import { defaultOptions, addLooseExports, SourceLocation, tokTypes, tokenizer, Node, lineBreak, isNewLine, getLineInfo, Token, lineBreakG } from './acorn.js';
import { defaultOptions, addLooseExports, SourceLocation, tokTypes, tokenizer, Node, lineBreak, isNewLine, getLineInfo, Token, lineBreakG } from './acorn';

@@ -1319,2 +1319,33 @@ // Registered plugins

// Acorn: Loose parser
//
// This module provides an alternative parser (`parse_dammit`) that
// exposes that same interface as `parse`, but will try to parse
// anything as JavaScript, repairing syntax error the best it can.
// There are circumstances in which it will raise an error and give
// up, but they are very rare. The resulting AST will be a mostly
// valid JavaScript AST (as per the [Mozilla parser API][api], except
// that:
//
// - Return outside functions is allowed
//
// - Label consistency (no conflicts, break only to existing labels)
// is not enforced.
//
// - Bogus Identifier nodes with a name of `"✖"` are inserted whenever
// the parser got too confused to return anything meaningful.
//
// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
//
// The expected use for this is to *first* try `acorn.parse`, and only
// if that fails switch to `parse_dammit`. The loose parser might
// parse badly indented code incorrectly, so **don't** use it as
// your default parser.
//
// Quite a lot of acorn.js is duplicated here. The alternative was to
// add a *lot* of extra cruft to that file, making it less readable
// and slower. Copying and editing the code allowed me to make
// invasive changes and simplifications without creating a complicated
// tangle.
defaultOptions.tabSize = 4

@@ -1321,0 +1352,0 @@

2273

dist/acorn_loose.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('./acorn.js')) :
typeof define === 'function' && define.amd ? define(['exports', './acorn.js'], factory) :
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('./acorn')) :
typeof define === 'function' && define.amd ? define(['exports', './acorn'], factory) :
(factory((global.acorn = global.acorn || {}, global.acorn.loose = global.acorn.loose || {}),global.acorn));
}(this, function (exports,__acorn_js) { 'use strict';
}(this, (function (exports,__acorn) { 'use strict';
// Registered plugins
var pluginsLoose = {}
// Registered plugins
var pluginsLoose = {}
var LooseParser = function LooseParser(input, options) {
if ( options === void 0 ) options = {};
var LooseParser = function LooseParser(input, options) {
if ( options === void 0 ) options = {};
this.toks = __acorn_js.tokenizer(input, options)
this.options = this.toks.options
this.input = this.toks.input
this.tok = this.last = {type: __acorn_js.tokTypes.eof, start: 0, end: 0}
if (this.options.locations) {
var here = this.toks.curPosition()
this.tok.loc = new __acorn_js.SourceLocation(this.toks, here, here)
}
this.ahead = [] // Tokens ahead
this.context = [] // Indentation contexted
this.curIndent = 0
this.curLineStart = 0
this.nextLineStart = this.lineEnd(this.curLineStart) + 1
this.inAsync = false
// Load plugins
this.options.pluginsLoose = options.pluginsLoose || {}
this.loadPlugins(this.options.pluginsLoose)
};
this.toks = __acorn.tokenizer(input, options)
this.options = this.toks.options
this.input = this.toks.input
this.tok = this.last = {type: __acorn.tokTypes.eof, start: 0, end: 0}
if (this.options.locations) {
var here = this.toks.curPosition()
this.tok.loc = new __acorn.SourceLocation(this.toks, here, here)
}
this.ahead = [] // Tokens ahead
this.context = [] // Indentation contexted
this.curIndent = 0
this.curLineStart = 0
this.nextLineStart = this.lineEnd(this.curLineStart) + 1
this.inAsync = false
// Load plugins
this.options.pluginsLoose = options.pluginsLoose || {}
this.loadPlugins(this.options.pluginsLoose)
};
LooseParser.prototype.startNode = function startNode () {
return new __acorn_js.Node(this.toks, this.tok.start, this.options.locations ? this.tok.loc.start : null)
};
LooseParser.prototype.startNode = function startNode () {
return new __acorn.Node(this.toks, this.tok.start, this.options.locations ? this.tok.loc.start : null)
};
LooseParser.prototype.storeCurrentPos = function storeCurrentPos () {
return this.options.locations ? [this.tok.start, this.tok.loc.start] : this.tok.start
};
LooseParser.prototype.storeCurrentPos = function storeCurrentPos () {
return this.options.locations ? [this.tok.start, this.tok.loc.start] : this.tok.start
};
LooseParser.prototype.startNodeAt = function startNodeAt (pos) {
if (this.options.locations) {
return new __acorn_js.Node(this.toks, pos[0], pos[1])
} else {
return new __acorn_js.Node(this.toks, pos)
}
};
LooseParser.prototype.startNodeAt = function startNodeAt (pos) {
if (this.options.locations) {
return new __acorn.Node(this.toks, pos[0], pos[1])
} else {
return new __acorn.Node(this.toks, pos)
}
};
LooseParser.prototype.finishNode = function finishNode (node, type) {
node.type = type
node.end = this.last.end
if (this.options.locations)
node.loc.end = this.last.loc.end
if (this.options.ranges)
node.range[1] = this.last.end
return node
};
LooseParser.prototype.finishNode = function finishNode (node, type) {
node.type = type
node.end = this.last.end
if (this.options.locations)
node.loc.end = this.last.loc.end
if (this.options.ranges)
node.range[1] = this.last.end
return node
};
LooseParser.prototype.dummyNode = function dummyNode (type) {
var dummy = this.startNode()
dummy.type = type
dummy.end = dummy.start
if (this.options.locations)
dummy.loc.end = dummy.loc.start
if (this.options.ranges)
dummy.range[1] = dummy.start
this.last = {type: __acorn_js.tokTypes.name, start: dummy.start, end: dummy.start, loc: dummy.loc}
return dummy
};
LooseParser.prototype.dummyNode = function dummyNode (type) {
var dummy = this.startNode()
dummy.type = type
dummy.end = dummy.start
if (this.options.locations)
dummy.loc.end = dummy.loc.start
if (this.options.ranges)
dummy.range[1] = dummy.start
this.last = {type: __acorn.tokTypes.name, start: dummy.start, end: dummy.start, loc: dummy.loc}
return dummy
};
LooseParser.prototype.dummyIdent = function dummyIdent () {
var dummy = this.dummyNode("Identifier")
dummy.name = "✖"
return dummy
};
LooseParser.prototype.dummyIdent = function dummyIdent () {
var dummy = this.dummyNode("Identifier")
dummy.name = "✖"
return dummy
};
LooseParser.prototype.dummyString = function dummyString () {
var dummy = this.dummyNode("Literal")
dummy.value = dummy.raw = "✖"
return dummy
};
LooseParser.prototype.dummyString = function dummyString () {
var dummy = this.dummyNode("Literal")
dummy.value = dummy.raw = "✖"
return dummy
};
LooseParser.prototype.eat = function eat (type) {
if (this.tok.type === type) {
this.next()
return true
} else {
return false
}
};
LooseParser.prototype.eat = function eat (type) {
if (this.tok.type === type) {
this.next()
return true
} else {
return false
}
};
LooseParser.prototype.isContextual = function isContextual (name) {
return this.tok.type === __acorn_js.tokTypes.name && this.tok.value === name
};
LooseParser.prototype.isContextual = function isContextual (name) {
return this.tok.type === __acorn.tokTypes.name && this.tok.value === name
};
LooseParser.prototype.eatContextual = function eatContextual (name) {
return this.tok.value === name && this.eat(__acorn_js.tokTypes.name)
};
LooseParser.prototype.eatContextual = function eatContextual (name) {
return this.tok.value === name && this.eat(__acorn.tokTypes.name)
};
LooseParser.prototype.canInsertSemicolon = function canInsertSemicolon () {
return this.tok.type === __acorn_js.tokTypes.eof || this.tok.type === __acorn_js.tokTypes.braceR ||
__acorn_js.lineBreak.test(this.input.slice(this.last.end, this.tok.start))
};
LooseParser.prototype.canInsertSemicolon = function canInsertSemicolon () {
return this.tok.type === __acorn.tokTypes.eof || this.tok.type === __acorn.tokTypes.braceR ||
__acorn.lineBreak.test(this.input.slice(this.last.end, this.tok.start))
};
LooseParser.prototype.semicolon = function semicolon () {
return this.eat(__acorn_js.tokTypes.semi)
};
LooseParser.prototype.semicolon = function semicolon () {
return this.eat(__acorn.tokTypes.semi)
};
LooseParser.prototype.expect = function expect (type) {
var this$1 = this;
LooseParser.prototype.expect = function expect (type) {
var this$1 = this;
if (this.eat(type)) return true
for (var i = 1; i <= 2; i++) {
if (this$1.lookAhead(i).type == type) {
for (var j = 0; j < i; j++) this$1.next()
return true
}
if (this.eat(type)) return true
for (var i = 1; i <= 2; i++) {
if (this$1.lookAhead(i).type == type) {
for (var j = 0; j < i; j++) this$1.next()
return true
}
};
}
};
LooseParser.prototype.pushCx = function pushCx () {
this.context.push(this.curIndent)
};
LooseParser.prototype.pushCx = function pushCx () {
this.context.push(this.curIndent)
};
LooseParser.prototype.popCx = function popCx () {
this.curIndent = this.context.pop()
};
LooseParser.prototype.popCx = function popCx () {
this.curIndent = this.context.pop()
};
LooseParser.prototype.lineEnd = function lineEnd (pos) {
while (pos < this.input.length && !__acorn_js.isNewLine(this.input.charCodeAt(pos))) ++pos
return pos
};
LooseParser.prototype.lineEnd = function lineEnd (pos) {
while (pos < this.input.length && !__acorn.isNewLine(this.input.charCodeAt(pos))) ++pos
return pos
};
LooseParser.prototype.indentationAfter = function indentationAfter (pos) {
var this$1 = this;
LooseParser.prototype.indentationAfter = function indentationAfter (pos) {
var this$1 = this;
for (var count = 0;; ++pos) {
var ch = this$1.input.charCodeAt(pos)
if (ch === 32) ++count
else if (ch === 9) count += this$1.options.tabSize
else return count
}
};
for (var count = 0;; ++pos) {
var ch = this$1.input.charCodeAt(pos)
if (ch === 32) ++count
else if (ch === 9) count += this$1.options.tabSize
else return count
}
};
LooseParser.prototype.closes = function closes (closeTok, indent, line, blockHeuristic) {
if (this.tok.type === closeTok || this.tok.type === __acorn_js.tokTypes.eof) return true
return line != this.curLineStart && this.curIndent < indent && this.tokenStartsLine() &&
(!blockHeuristic || this.nextLineStart >= this.input.length ||
this.indentationAfter(this.nextLineStart) < indent)
};
LooseParser.prototype.closes = function closes (closeTok, indent, line, blockHeuristic) {
if (this.tok.type === closeTok || this.tok.type === __acorn.tokTypes.eof) return true
return line != this.curLineStart && this.curIndent < indent && this.tokenStartsLine() &&
(!blockHeuristic || this.nextLineStart >= this.input.length ||
this.indentationAfter(this.nextLineStart) < indent)
};
LooseParser.prototype.tokenStartsLine = function tokenStartsLine () {
var this$1 = this;
LooseParser.prototype.tokenStartsLine = function tokenStartsLine () {
var this$1 = this;
for (var p = this.tok.start - 1; p >= this.curLineStart; --p) {
var ch = this$1.input.charCodeAt(p)
if (ch !== 9 && ch !== 32) return false
}
return true
};
for (var p = this.tok.start - 1; p >= this.curLineStart; --p) {
var ch = this$1.input.charCodeAt(p)
if (ch !== 9 && ch !== 32) return false
}
return true
};
LooseParser.prototype.extend = function extend (name, f) {
this[name] = f(this[name])
};
LooseParser.prototype.extend = function extend (name, f) {
this[name] = f(this[name])
};
LooseParser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {
var this$1 = this;
LooseParser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {
var this$1 = this;
for (var name in pluginConfigs) {
var plugin = pluginsLoose[name]
if (!plugin) throw new Error("Plugin '" + name + "' not found")
plugin(this$1, pluginConfigs[name])
}
};
for (var name in pluginConfigs) {
var plugin = pluginsLoose[name]
if (!plugin) throw new Error("Plugin '" + name + "' not found")
plugin(this$1, pluginConfigs[name])
}
};
var lp = LooseParser.prototype
var lp = LooseParser.prototype
function isSpace(ch) {
return (ch < 14 && ch > 8) || ch === 32 || ch === 160 || __acorn_js.isNewLine(ch)
}
function isSpace(ch) {
return (ch < 14 && ch > 8) || ch === 32 || ch === 160 || __acorn.isNewLine(ch)
}
lp.next = function() {
var this$1 = this;
lp.next = function() {
var this$1 = this;
this.last = this.tok
if (this.ahead.length)
this.tok = this.ahead.shift()
else
this.tok = this.readToken()
this.last = this.tok
if (this.ahead.length)
this.tok = this.ahead.shift()
else
this.tok = this.readToken()
if (this.tok.start >= this.nextLineStart) {
while (this.tok.start >= this.nextLineStart) {
this$1.curLineStart = this$1.nextLineStart
this$1.nextLineStart = this$1.lineEnd(this$1.curLineStart) + 1
}
this.curIndent = this.indentationAfter(this.curLineStart)
if (this.tok.start >= this.nextLineStart) {
while (this.tok.start >= this.nextLineStart) {
this$1.curLineStart = this$1.nextLineStart
this$1.nextLineStart = this$1.lineEnd(this$1.curLineStart) + 1
}
this.curIndent = this.indentationAfter(this.curLineStart)
}
}
lp.readToken = function() {
var this$1 = this;
lp.readToken = function() {
var this$1 = this;
for (;;) {
try {
this$1.toks.next()
if (this$1.toks.type === __acorn_js.tokTypes.dot &&
this$1.input.substr(this$1.toks.end, 1) === "." &&
this$1.options.ecmaVersion >= 6) {
this$1.toks.end++
this$1.toks.type = __acorn_js.tokTypes.ellipsis
}
return new __acorn_js.Token(this$1.toks)
} catch(e) {
if (!(e instanceof SyntaxError)) throw e
for (;;) {
try {
this$1.toks.next()
if (this$1.toks.type === __acorn.tokTypes.dot &&
this$1.input.substr(this$1.toks.end, 1) === "." &&
this$1.options.ecmaVersion >= 6) {
this$1.toks.end++
this$1.toks.type = __acorn.tokTypes.ellipsis
}
return new __acorn.Token(this$1.toks)
} catch(e) {
if (!(e instanceof SyntaxError)) throw e
// Try to skip some text, based on the error message, and then continue
var msg = e.message, pos = e.raisedAt, replace = true
if (/unterminated/i.test(msg)) {
pos = this$1.lineEnd(e.pos + 1)
if (/string/.test(msg)) {
replace = {start: e.pos, end: pos, type: __acorn_js.tokTypes.string, value: this$1.input.slice(e.pos + 1, pos)}
} else if (/regular expr/i.test(msg)) {
var re = this$1.input.slice(e.pos, pos)
try { re = new RegExp(re) } catch(e) {}
replace = {start: e.pos, end: pos, type: __acorn_js.tokTypes.regexp, value: re}
} else if (/template/.test(msg)) {
replace = {start: e.pos, end: pos,
type: __acorn_js.tokTypes.template,
value: this$1.input.slice(e.pos, pos)}
} else {
replace = false
}
} else if (/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number|expected number in radix/i.test(msg)) {
while (pos < this.input.length && !isSpace(this.input.charCodeAt(pos))) ++pos
} else if (/character escape|expected hexadecimal/i.test(msg)) {
while (pos < this.input.length) {
var ch = this$1.input.charCodeAt(pos++)
if (ch === 34 || ch === 39 || __acorn_js.isNewLine(ch)) break
}
} else if (/unexpected character/i.test(msg)) {
pos++
// Try to skip some text, based on the error message, and then continue
var msg = e.message, pos = e.raisedAt, replace = true
if (/unterminated/i.test(msg)) {
pos = this$1.lineEnd(e.pos + 1)
if (/string/.test(msg)) {
replace = {start: e.pos, end: pos, type: __acorn.tokTypes.string, value: this$1.input.slice(e.pos + 1, pos)}
} else if (/regular expr/i.test(msg)) {
var re = this$1.input.slice(e.pos, pos)
try { re = new RegExp(re) } catch(e) {}
replace = {start: e.pos, end: pos, type: __acorn.tokTypes.regexp, value: re}
} else if (/template/.test(msg)) {
replace = {start: e.pos, end: pos,
type: __acorn.tokTypes.template,
value: this$1.input.slice(e.pos, pos)}
} else {
replace = false
} else if (/regular expression/i.test(msg)) {
replace = true
} else {
throw e
}
this$1.resetTo(pos)
if (replace === true) replace = {start: pos, end: pos, type: __acorn_js.tokTypes.name, value: "✖"}
if (replace) {
if (this$1.options.locations)
replace.loc = new __acorn_js.SourceLocation(
this$1.toks,
__acorn_js.getLineInfo(this$1.input, replace.start),
__acorn_js.getLineInfo(this$1.input, replace.end))
return replace
} else if (/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number|expected number in radix/i.test(msg)) {
while (pos < this.input.length && !isSpace(this.input.charCodeAt(pos))) ++pos
} else if (/character escape|expected hexadecimal/i.test(msg)) {
while (pos < this.input.length) {
var ch = this$1.input.charCodeAt(pos++)
if (ch === 34 || ch === 39 || __acorn.isNewLine(ch)) break
}
} else if (/unexpected character/i.test(msg)) {
pos++
replace = false
} else if (/regular expression/i.test(msg)) {
replace = true
} else {
throw e
}
this$1.resetTo(pos)
if (replace === true) replace = {start: pos, end: pos, type: __acorn.tokTypes.name, value: "✖"}
if (replace) {
if (this$1.options.locations)
replace.loc = new __acorn.SourceLocation(
this$1.toks,
__acorn.getLineInfo(this$1.input, replace.start),
__acorn.getLineInfo(this$1.input, replace.end))
return replace
}
}
}
}
lp.resetTo = function(pos) {
var this$1 = this;
lp.resetTo = function(pos) {
var this$1 = this;
this.toks.pos = pos
var ch = this.input.charAt(pos - 1)
this.toks.exprAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
/[enwfd]/.test(ch) &&
/\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(this.input.slice(pos - 10, pos))
this.toks.pos = pos
var ch = this.input.charAt(pos - 1)
this.toks.exprAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
/[enwfd]/.test(ch) &&
/\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(this.input.slice(pos - 10, pos))
if (this.options.locations) {
this.toks.curLine = 1
this.toks.lineStart = __acorn_js.lineBreakG.lastIndex = 0
var match
while ((match = __acorn_js.lineBreakG.exec(this.input)) && match.index < pos) {
++this$1.toks.curLine
this$1.toks.lineStart = match.index + match[0].length
}
if (this.options.locations) {
this.toks.curLine = 1
this.toks.lineStart = __acorn.lineBreakG.lastIndex = 0
var match
while ((match = __acorn.lineBreakG.exec(this.input)) && match.index < pos) {
++this$1.toks.curLine
this$1.toks.lineStart = match.index + match[0].length
}
}
}
lp.lookAhead = function(n) {
var this$1 = this;
lp.lookAhead = function(n) {
var this$1 = this;
while (n > this.ahead.length)
this$1.ahead.push(this$1.readToken())
return this.ahead[n - 1]
}
while (n > this.ahead.length)
this$1.ahead.push(this$1.readToken())
return this.ahead[n - 1]
}
function isDummy(node) { return node.name == "✖" }
function isDummy(node) { return node.name == "✖" }
var lp$1 = LooseParser.prototype
var lp$1 = LooseParser.prototype
lp$1.parseTopLevel = function() {
var this$1 = this;
lp$1.parseTopLevel = function() {
var this$1 = this;
var node = this.startNodeAt(this.options.locations ? [0, __acorn_js.getLineInfo(this.input, 0)] : 0)
node.body = []
while (this.tok.type !== __acorn_js.tokTypes.eof) node.body.push(this$1.parseStatement())
this.last = this.tok
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType
}
return this.finishNode(node, "Program")
var node = this.startNodeAt(this.options.locations ? [0, __acorn.getLineInfo(this.input, 0)] : 0)
node.body = []
while (this.tok.type !== __acorn.tokTypes.eof) node.body.push(this$1.parseStatement())
this.last = this.tok
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType
}
return this.finishNode(node, "Program")
}
lp$1.parseStatement = function() {
var this$1 = this;
lp$1.parseStatement = function() {
var this$1 = this;
var starttype = this.tok.type, node = this.startNode(), kind
var starttype = this.tok.type, node = this.startNode(), kind
if (this.toks.isLet()) {
starttype = __acorn_js.tokTypes._var
kind = "let"
if (this.toks.isLet()) {
starttype = __acorn.tokTypes._var
kind = "let"
}
switch (starttype) {
case __acorn.tokTypes._break: case __acorn.tokTypes._continue:
this.next()
var isBreak = starttype === __acorn.tokTypes._break
if (this.semicolon() || this.canInsertSemicolon()) {
node.label = null
} else {
node.label = this.tok.type === __acorn.tokTypes.name ? this.parseIdent() : null
this.semicolon()
}
return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
switch (starttype) {
case __acorn_js.tokTypes._break: case __acorn_js.tokTypes._continue:
this.next()
var isBreak = starttype === __acorn_js.tokTypes._break
if (this.semicolon() || this.canInsertSemicolon()) {
node.label = null
} else {
node.label = this.tok.type === __acorn_js.tokTypes.name ? this.parseIdent() : null
this.semicolon()
}
return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
case __acorn.tokTypes._debugger:
this.next()
this.semicolon()
return this.finishNode(node, "DebuggerStatement")
case __acorn_js.tokTypes._debugger:
this.next()
this.semicolon()
return this.finishNode(node, "DebuggerStatement")
case __acorn.tokTypes._do:
this.next()
node.body = this.parseStatement()
node.test = this.eat(__acorn.tokTypes._while) ? this.parseParenExpression() : this.dummyIdent()
this.semicolon()
return this.finishNode(node, "DoWhileStatement")
case __acorn_js.tokTypes._do:
this.next()
node.body = this.parseStatement()
node.test = this.eat(__acorn_js.tokTypes._while) ? this.parseParenExpression() : this.dummyIdent()
this.semicolon()
return this.finishNode(node, "DoWhileStatement")
case __acorn_js.tokTypes._for:
this.next()
this.pushCx()
this.expect(__acorn_js.tokTypes.parenL)
if (this.tok.type === __acorn_js.tokTypes.semi) return this.parseFor(node, null)
var isLet = this.toks.isLet()
if (isLet || this.tok.type === __acorn_js.tokTypes._var || this.tok.type === __acorn_js.tokTypes._const) {
var init$1 = this.parseVar(true, isLet ? "let" : this.tok.value)
if (init$1.declarations.length === 1 && (this.tok.type === __acorn_js.tokTypes._in || this.isContextual("of"))) {
return this.parseForIn(node, init$1)
}
return this.parseFor(node, init$1)
case __acorn.tokTypes._for:
this.next()
this.pushCx()
this.expect(__acorn.tokTypes.parenL)
if (this.tok.type === __acorn.tokTypes.semi) return this.parseFor(node, null)
var isLet = this.toks.isLet()
if (isLet || this.tok.type === __acorn.tokTypes._var || this.tok.type === __acorn.tokTypes._const) {
var init$1 = this.parseVar(true, isLet ? "let" : this.tok.value)
if (init$1.declarations.length === 1 && (this.tok.type === __acorn.tokTypes._in || this.isContextual("of"))) {
return this.parseForIn(node, init$1)
}
var init = this.parseExpression(true)
if (this.tok.type === __acorn_js.tokTypes._in || this.isContextual("of"))
return this.parseForIn(node, this.toAssignable(init))
return this.parseFor(node, init)
return this.parseFor(node, init$1)
}
var init = this.parseExpression(true)
if (this.tok.type === __acorn.tokTypes._in || this.isContextual("of"))
return this.parseForIn(node, this.toAssignable(init))
return this.parseFor(node, init)
case __acorn_js.tokTypes._function:
this.next()
return this.parseFunction(node, true)
case __acorn.tokTypes._function:
this.next()
return this.parseFunction(node, true)
case __acorn_js.tokTypes._if:
this.next()
node.test = this.parseParenExpression()
node.consequent = this.parseStatement()
node.alternate = this.eat(__acorn_js.tokTypes._else) ? this.parseStatement() : null
return this.finishNode(node, "IfStatement")
case __acorn.tokTypes._if:
this.next()
node.test = this.parseParenExpression()
node.consequent = this.parseStatement()
node.alternate = this.eat(__acorn.tokTypes._else) ? this.parseStatement() : null
return this.finishNode(node, "IfStatement")
case __acorn_js.tokTypes._return:
this.next()
if (this.eat(__acorn_js.tokTypes.semi) || this.canInsertSemicolon()) node.argument = null
else { node.argument = this.parseExpression(); this.semicolon() }
return this.finishNode(node, "ReturnStatement")
case __acorn.tokTypes._return:
this.next()
if (this.eat(__acorn.tokTypes.semi) || this.canInsertSemicolon()) node.argument = null
else { node.argument = this.parseExpression(); this.semicolon() }
return this.finishNode(node, "ReturnStatement")
case __acorn_js.tokTypes._switch:
var blockIndent = this.curIndent, line = this.curLineStart
this.next()
node.discriminant = this.parseParenExpression()
node.cases = []
this.pushCx()
this.expect(__acorn_js.tokTypes.braceL)
case __acorn.tokTypes._switch:
var blockIndent = this.curIndent, line = this.curLineStart
this.next()
node.discriminant = this.parseParenExpression()
node.cases = []
this.pushCx()
this.expect(__acorn.tokTypes.braceL)
var cur
while (!this.closes(__acorn_js.tokTypes.braceR, blockIndent, line, true)) {
if (this$1.tok.type === __acorn_js.tokTypes._case || this$1.tok.type === __acorn_js.tokTypes._default) {
var isCase = this$1.tok.type === __acorn_js.tokTypes._case
if (cur) this$1.finishNode(cur, "SwitchCase")
var cur
while (!this.closes(__acorn.tokTypes.braceR, blockIndent, line, true)) {
if (this$1.tok.type === __acorn.tokTypes._case || this$1.tok.type === __acorn.tokTypes._default) {
var isCase = this$1.tok.type === __acorn.tokTypes._case
if (cur) this$1.finishNode(cur, "SwitchCase")
node.cases.push(cur = this$1.startNode())
cur.consequent = []
this$1.next()
if (isCase) cur.test = this$1.parseExpression()
else cur.test = null
this$1.expect(__acorn.tokTypes.colon)
} else {
if (!cur) {
node.cases.push(cur = this$1.startNode())
cur.consequent = []
this$1.next()
if (isCase) cur.test = this$1.parseExpression()
else cur.test = null
this$1.expect(__acorn_js.tokTypes.colon)
} else {
if (!cur) {
node.cases.push(cur = this$1.startNode())
cur.consequent = []
cur.test = null
}
cur.consequent.push(this$1.parseStatement())
cur.test = null
}
cur.consequent.push(this$1.parseStatement())
}
if (cur) this.finishNode(cur, "SwitchCase")
this.popCx()
this.eat(__acorn_js.tokTypes.braceR)
return this.finishNode(node, "SwitchStatement")
}
if (cur) this.finishNode(cur, "SwitchCase")
this.popCx()
this.eat(__acorn.tokTypes.braceR)
return this.finishNode(node, "SwitchStatement")
case __acorn_js.tokTypes._throw:
this.next()
node.argument = this.parseExpression()
this.semicolon()
return this.finishNode(node, "ThrowStatement")
case __acorn.tokTypes._throw:
this.next()
node.argument = this.parseExpression()
this.semicolon()
return this.finishNode(node, "ThrowStatement")
case __acorn_js.tokTypes._try:
case __acorn.tokTypes._try:
this.next()
node.block = this.parseBlock()
node.handler = null
if (this.tok.type === __acorn.tokTypes._catch) {
var clause = this.startNode()
this.next()
node.block = this.parseBlock()
node.handler = null
if (this.tok.type === __acorn_js.tokTypes._catch) {
var clause = this.startNode()
this.next()
this.expect(__acorn_js.tokTypes.parenL)
clause.param = this.toAssignable(this.parseExprAtom(), true)
this.expect(__acorn_js.tokTypes.parenR)
clause.body = this.parseBlock()
node.handler = this.finishNode(clause, "CatchClause")
}
node.finalizer = this.eat(__acorn_js.tokTypes._finally) ? this.parseBlock() : null
if (!node.handler && !node.finalizer) return node.block
return this.finishNode(node, "TryStatement")
this.expect(__acorn.tokTypes.parenL)
clause.param = this.toAssignable(this.parseExprAtom(), true)
this.expect(__acorn.tokTypes.parenR)
clause.body = this.parseBlock()
node.handler = this.finishNode(clause, "CatchClause")
}
node.finalizer = this.eat(__acorn.tokTypes._finally) ? this.parseBlock() : null
if (!node.handler && !node.finalizer) return node.block
return this.finishNode(node, "TryStatement")
case __acorn_js.tokTypes._var:
case __acorn_js.tokTypes._const:
return this.parseVar(false, kind || this.tok.value)
case __acorn.tokTypes._var:
case __acorn.tokTypes._const:
return this.parseVar(false, kind || this.tok.value)
case __acorn_js.tokTypes._while:
this.next()
node.test = this.parseParenExpression()
node.body = this.parseStatement()
return this.finishNode(node, "WhileStatement")
case __acorn.tokTypes._while:
this.next()
node.test = this.parseParenExpression()
node.body = this.parseStatement()
return this.finishNode(node, "WhileStatement")
case __acorn_js.tokTypes._with:
this.next()
node.object = this.parseParenExpression()
node.body = this.parseStatement()
return this.finishNode(node, "WithStatement")
case __acorn.tokTypes._with:
this.next()
node.object = this.parseParenExpression()
node.body = this.parseStatement()
return this.finishNode(node, "WithStatement")
case __acorn_js.tokTypes.braceL:
return this.parseBlock()
case __acorn.tokTypes.braceL:
return this.parseBlock()
case __acorn_js.tokTypes.semi:
this.next()
return this.finishNode(node, "EmptyStatement")
case __acorn.tokTypes.semi:
this.next()
return this.finishNode(node, "EmptyStatement")
case __acorn_js.tokTypes._class:
return this.parseClass(true)
case __acorn.tokTypes._class:
return this.parseClass(true)
case __acorn_js.tokTypes._import:
return this.parseImport()
case __acorn.tokTypes._import:
return this.parseImport()
case __acorn_js.tokTypes._export:
return this.parseExport()
case __acorn.tokTypes._export:
return this.parseExport()
default:
if (this.toks.isAsyncFunction()) {
this.next()
this.next()
return this.parseFunction(node, true, true)
}
var expr = this.parseExpression()
if (isDummy(expr)) {
this.next()
if (this.tok.type === __acorn_js.tokTypes.eof) return this.finishNode(node, "EmptyStatement")
return this.parseStatement()
} else if (starttype === __acorn_js.tokTypes.name && expr.type === "Identifier" && this.eat(__acorn_js.tokTypes.colon)) {
node.body = this.parseStatement()
node.label = expr
return this.finishNode(node, "LabeledStatement")
} else {
node.expression = expr
this.semicolon()
return this.finishNode(node, "ExpressionStatement")
}
default:
if (this.toks.isAsyncFunction()) {
this.next()
this.next()
return this.parseFunction(node, true, true)
}
var expr = this.parseExpression()
if (isDummy(expr)) {
this.next()
if (this.tok.type === __acorn.tokTypes.eof) return this.finishNode(node, "EmptyStatement")
return this.parseStatement()
} else if (starttype === __acorn.tokTypes.name && expr.type === "Identifier" && this.eat(__acorn.tokTypes.colon)) {
node.body = this.parseStatement()
node.label = expr
return this.finishNode(node, "LabeledStatement")
} else {
node.expression = expr
this.semicolon()
return this.finishNode(node, "ExpressionStatement")
}
}
}
lp$1.parseBlock = function() {
var this$1 = this;
lp$1.parseBlock = function() {
var this$1 = this;
var node = this.startNode()
this.pushCx()
this.expect(__acorn_js.tokTypes.braceL)
var blockIndent = this.curIndent, line = this.curLineStart
node.body = []
while (!this.closes(__acorn_js.tokTypes.braceR, blockIndent, line, true))
node.body.push(this$1.parseStatement())
this.popCx()
this.eat(__acorn_js.tokTypes.braceR)
return this.finishNode(node, "BlockStatement")
}
var node = this.startNode()
this.pushCx()
this.expect(__acorn.tokTypes.braceL)
var blockIndent = this.curIndent, line = this.curLineStart
node.body = []
while (!this.closes(__acorn.tokTypes.braceR, blockIndent, line, true))
node.body.push(this$1.parseStatement())
this.popCx()
this.eat(__acorn.tokTypes.braceR)
return this.finishNode(node, "BlockStatement")
}
lp$1.parseFor = function(node, init) {
node.init = init
node.test = node.update = null
if (this.eat(__acorn_js.tokTypes.semi) && this.tok.type !== __acorn_js.tokTypes.semi) node.test = this.parseExpression()
if (this.eat(__acorn_js.tokTypes.semi) && this.tok.type !== __acorn_js.tokTypes.parenR) node.update = this.parseExpression()
this.popCx()
this.expect(__acorn_js.tokTypes.parenR)
node.body = this.parseStatement()
return this.finishNode(node, "ForStatement")
}
lp$1.parseFor = function(node, init) {
node.init = init
node.test = node.update = null
if (this.eat(__acorn.tokTypes.semi) && this.tok.type !== __acorn.tokTypes.semi) node.test = this.parseExpression()
if (this.eat(__acorn.tokTypes.semi) && this.tok.type !== __acorn.tokTypes.parenR) node.update = this.parseExpression()
this.popCx()
this.expect(__acorn.tokTypes.parenR)
node.body = this.parseStatement()
return this.finishNode(node, "ForStatement")
}
lp$1.parseForIn = function(node, init) {
var type = this.tok.type === __acorn_js.tokTypes._in ? "ForInStatement" : "ForOfStatement"
this.next()
node.left = init
node.right = this.parseExpression()
this.popCx()
this.expect(__acorn_js.tokTypes.parenR)
node.body = this.parseStatement()
return this.finishNode(node, type)
}
lp$1.parseForIn = function(node, init) {
var type = this.tok.type === __acorn.tokTypes._in ? "ForInStatement" : "ForOfStatement"
this.next()
node.left = init
node.right = this.parseExpression()
this.popCx()
this.expect(__acorn.tokTypes.parenR)
node.body = this.parseStatement()
return this.finishNode(node, type)
}
lp$1.parseVar = function(noIn, kind) {
var this$1 = this;
lp$1.parseVar = function(noIn, kind) {
var this$1 = this;
var node = this.startNode()
node.kind = kind
this.next()
node.declarations = []
do {
var decl = this$1.startNode()
decl.id = this$1.options.ecmaVersion >= 6 ? this$1.toAssignable(this$1.parseExprAtom(), true) : this$1.parseIdent()
decl.init = this$1.eat(__acorn_js.tokTypes.eq) ? this$1.parseMaybeAssign(noIn) : null
node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"))
} while (this.eat(__acorn_js.tokTypes.comma))
if (!node.declarations.length) {
var decl$1 = this.startNode()
decl$1.id = this.dummyIdent()
node.declarations.push(this.finishNode(decl$1, "VariableDeclarator"))
}
if (!noIn) this.semicolon()
return this.finishNode(node, "VariableDeclaration")
var node = this.startNode()
node.kind = kind
this.next()
node.declarations = []
do {
var decl = this$1.startNode()
decl.id = this$1.options.ecmaVersion >= 6 ? this$1.toAssignable(this$1.parseExprAtom(), true) : this$1.parseIdent()
decl.init = this$1.eat(__acorn.tokTypes.eq) ? this$1.parseMaybeAssign(noIn) : null
node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"))
} while (this.eat(__acorn.tokTypes.comma))
if (!node.declarations.length) {
var decl$1 = this.startNode()
decl$1.id = this.dummyIdent()
node.declarations.push(this.finishNode(decl$1, "VariableDeclarator"))
}
if (!noIn) this.semicolon()
return this.finishNode(node, "VariableDeclaration")
}
lp$1.parseClass = function(isStatement) {
var this$1 = this;
lp$1.parseClass = function(isStatement) {
var this$1 = this;
var node = this.startNode()
this.next()
if (this.tok.type === __acorn_js.tokTypes.name) node.id = this.parseIdent()
else if (isStatement) node.id = this.dummyIdent()
else node.id = null
node.superClass = this.eat(__acorn_js.tokTypes._extends) ? this.parseExpression() : null
node.body = this.startNode()
node.body.body = []
this.pushCx()
var indent = this.curIndent + 1, line = this.curLineStart
this.eat(__acorn_js.tokTypes.braceL)
if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
while (!this.closes(__acorn_js.tokTypes.braceR, indent, line)) {
if (this$1.semicolon()) continue
var method = this$1.startNode(), isGenerator, isAsync
if (this$1.options.ecmaVersion >= 6) {
method.static = false
isGenerator = this$1.eat(__acorn_js.tokTypes.star)
}
var node = this.startNode()
this.next()
if (this.tok.type === __acorn.tokTypes.name) node.id = this.parseIdent()
else if (isStatement) node.id = this.dummyIdent()
else node.id = null
node.superClass = this.eat(__acorn.tokTypes._extends) ? this.parseExpression() : null
node.body = this.startNode()
node.body.body = []
this.pushCx()
var indent = this.curIndent + 1, line = this.curLineStart
this.eat(__acorn.tokTypes.braceL)
if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
while (!this.closes(__acorn.tokTypes.braceR, indent, line)) {
if (this$1.semicolon()) continue
var method = this$1.startNode(), isGenerator, isAsync
if (this$1.options.ecmaVersion >= 6) {
method.static = false
isGenerator = this$1.eat(__acorn.tokTypes.star)
}
this$1.parsePropertyName(method)
if (isDummy(method.key)) { if (isDummy(this$1.parseMaybeAssign())) this$1.next(); this$1.eat(__acorn.tokTypes.comma); continue }
if (method.key.type === "Identifier" && !method.computed && method.key.name === "static" &&
(this$1.tok.type != __acorn.tokTypes.parenL && this$1.tok.type != __acorn.tokTypes.braceL)) {
method.static = true
isGenerator = this$1.eat(__acorn.tokTypes.star)
this$1.parsePropertyName(method)
if (isDummy(method.key)) { if (isDummy(this$1.parseMaybeAssign())) this$1.next(); this$1.eat(__acorn_js.tokTypes.comma); continue }
if (method.key.type === "Identifier" && !method.computed && method.key.name === "static" &&
(this$1.tok.type != __acorn_js.tokTypes.parenL && this$1.tok.type != __acorn_js.tokTypes.braceL)) {
method.static = true
isGenerator = this$1.eat(__acorn_js.tokTypes.star)
this$1.parsePropertyName(method)
} else {
method.static = false
}
if (!method.computed &&
method.key.type === "Identifier" && method.key.name === "async" && this$1.tok.type !== __acorn.tokTypes.parenL &&
!this$1.canInsertSemicolon()) {
this$1.parsePropertyName(method)
isAsync = true
} else {
isAsync = false
}
if (this$1.options.ecmaVersion >= 5 && method.key.type === "Identifier" &&
!method.computed && (method.key.name === "get" || method.key.name === "set") &&
this$1.tok.type !== __acorn.tokTypes.parenL && this$1.tok.type !== __acorn.tokTypes.braceL) {
method.kind = method.key.name
this$1.parsePropertyName(method)
method.value = this$1.parseMethod(false)
} else {
if (!method.computed && !method.static && !isGenerator && !isAsync && (
method.key.type === "Identifier" && method.key.name === "constructor" ||
method.key.type === "Literal" && method.key.value === "constructor")) {
method.kind = "constructor"
} else {
method.static = false
method.kind = "method"
}
if (!method.computed &&
method.key.type === "Identifier" && method.key.name === "async" && this$1.tok.type !== __acorn_js.tokTypes.parenL &&
!this$1.canInsertSemicolon()) {
this$1.parsePropertyName(method)
isAsync = true
} else {
isAsync = false
}
if (this$1.options.ecmaVersion >= 5 && method.key.type === "Identifier" &&
!method.computed && (method.key.name === "get" || method.key.name === "set") &&
this$1.tok.type !== __acorn_js.tokTypes.parenL && this$1.tok.type !== __acorn_js.tokTypes.braceL) {
method.kind = method.key.name
this$1.parsePropertyName(method)
method.value = this$1.parseMethod(false)
} else {
if (!method.computed && !method.static && !isGenerator && !isAsync && (
method.key.type === "Identifier" && method.key.name === "constructor" ||
method.key.type === "Literal" && method.key.value === "constructor")) {
method.kind = "constructor"
} else {
method.kind = "method"
}
method.value = this$1.parseMethod(isGenerator, isAsync)
}
node.body.body.push(this$1.finishNode(method, "MethodDefinition"))
method.value = this$1.parseMethod(isGenerator, isAsync)
}
this.popCx()
if (!this.eat(__acorn_js.tokTypes.braceR)) {
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
this.last.end = this.tok.start
if (this.options.locations) this.last.loc.end = this.tok.loc.start
}
this.semicolon()
this.finishNode(node.body, "ClassBody")
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
node.body.body.push(this$1.finishNode(method, "MethodDefinition"))
}
this.popCx()
if (!this.eat(__acorn.tokTypes.braceR)) {
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
this.last.end = this.tok.start
if (this.options.locations) this.last.loc.end = this.tok.loc.start
}
this.semicolon()
this.finishNode(node.body, "ClassBody")
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
}
lp$1.parseFunction = function(node, isStatement, isAsync) {
var oldInAsync = this.inAsync
this.initFunction(node)
if (this.options.ecmaVersion >= 6) {
node.generator = this.eat(__acorn_js.tokTypes.star)
}
if (this.options.ecmaVersion >= 8) {
node.async = !!isAsync
}
if (this.tok.type === __acorn_js.tokTypes.name) node.id = this.parseIdent()
else if (isStatement) node.id = this.dummyIdent()
this.inAsync = node.async
node.params = this.parseFunctionParams()
node.body = this.parseBlock()
this.inAsync = oldInAsync
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
lp$1.parseFunction = function(node, isStatement, isAsync) {
var oldInAsync = this.inAsync
this.initFunction(node)
if (this.options.ecmaVersion >= 6) {
node.generator = this.eat(__acorn.tokTypes.star)
}
if (this.options.ecmaVersion >= 8) {
node.async = !!isAsync
}
if (this.tok.type === __acorn.tokTypes.name) node.id = this.parseIdent()
else if (isStatement) node.id = this.dummyIdent()
this.inAsync = node.async
node.params = this.parseFunctionParams()
node.body = this.parseBlock()
this.inAsync = oldInAsync
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
}
lp$1.parseExport = function() {
var node = this.startNode()
this.next()
if (this.eat(__acorn_js.tokTypes.star)) {
node.source = this.eatContextual("from") ? this.parseExprAtom() : this.dummyString()
return this.finishNode(node, "ExportAllDeclaration")
}
if (this.eat(__acorn_js.tokTypes._default)) {
// export default (function foo() {}) // This is FunctionExpression.
var isParenL = this.tok.type === __acorn_js.tokTypes.parenL
var expr = this.parseMaybeAssign()
if (!isParenL && expr.id) {
switch (expr.type) {
case "FunctionExpression": expr.type = "FunctionDeclaration"; break
case "ClassExpression": expr.type = "ClassDeclaration"; break
}
}
node.declaration = expr
this.semicolon()
return this.finishNode(node, "ExportDefaultDeclaration")
}
if (this.tok.type.keyword || this.toks.isLet() || this.toks.isAsyncFunction()) {
node.declaration = this.parseStatement()
node.specifiers = []
node.source = null
} else {
node.declaration = null
node.specifiers = this.parseExportSpecifierList()
node.source = this.eatContextual("from") ? this.parseExprAtom() : null
this.semicolon()
}
return this.finishNode(node, "ExportNamedDeclaration")
lp$1.parseExport = function() {
var node = this.startNode()
this.next()
if (this.eat(__acorn.tokTypes.star)) {
node.source = this.eatContextual("from") ? this.parseExprAtom() : this.dummyString()
return this.finishNode(node, "ExportAllDeclaration")
}
lp$1.parseImport = function() {
var node = this.startNode()
this.next()
if (this.tok.type === __acorn_js.tokTypes.string) {
node.specifiers = []
node.source = this.parseExprAtom()
node.kind = ''
} else {
var elt
if (this.tok.type === __acorn_js.tokTypes.name && this.tok.value !== "from") {
elt = this.startNode()
elt.local = this.parseIdent()
this.finishNode(elt, "ImportDefaultSpecifier")
this.eat(__acorn_js.tokTypes.comma)
if (this.eat(__acorn.tokTypes._default)) {
// export default (function foo() {}) // This is FunctionExpression.
var isParenL = this.tok.type === __acorn.tokTypes.parenL
var expr = this.parseMaybeAssign()
if (!isParenL && expr.id) {
switch (expr.type) {
case "FunctionExpression": expr.type = "FunctionDeclaration"; break
case "ClassExpression": expr.type = "ClassDeclaration"; break
}
node.specifiers = this.parseImportSpecifierList()
node.source = this.eatContextual("from") && this.tok.type == __acorn_js.tokTypes.string ? this.parseExprAtom() : this.dummyString()
if (elt) node.specifiers.unshift(elt)
}
node.declaration = expr
this.semicolon()
return this.finishNode(node, "ImportDeclaration")
return this.finishNode(node, "ExportDefaultDeclaration")
}
if (this.tok.type.keyword || this.toks.isLet() || this.toks.isAsyncFunction()) {
node.declaration = this.parseStatement()
node.specifiers = []
node.source = null
} else {
node.declaration = null
node.specifiers = this.parseExportSpecifierList()
node.source = this.eatContextual("from") ? this.parseExprAtom() : null
this.semicolon()
}
return this.finishNode(node, "ExportNamedDeclaration")
}
lp$1.parseImportSpecifierList = function() {
var this$1 = this;
var elts = []
if (this.tok.type === __acorn_js.tokTypes.star) {
var elt = this.startNode()
this.next()
elt.local = this.eatContextual("as") ? this.parseIdent() : this.dummyIdent()
elts.push(this.finishNode(elt, "ImportNamespaceSpecifier"))
} else {
var indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
this.pushCx()
this.eat(__acorn_js.tokTypes.braceL)
if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
while (!this.closes(__acorn_js.tokTypes.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
var elt$1 = this$1.startNode()
if (this$1.eat(__acorn_js.tokTypes.star)) {
elt$1.local = this$1.eatContextual("as") ? this$1.parseIdent() : this$1.dummyIdent()
this$1.finishNode(elt$1, "ImportNamespaceSpecifier")
} else {
if (this$1.isContextual("from")) break
elt$1.imported = this$1.parseIdent()
if (isDummy(elt$1.imported)) break
elt$1.local = this$1.eatContextual("as") ? this$1.parseIdent() : elt$1.imported
this$1.finishNode(elt$1, "ImportSpecifier")
}
elts.push(elt$1)
this$1.eat(__acorn_js.tokTypes.comma)
}
this.eat(__acorn_js.tokTypes.braceR)
this.popCx()
lp$1.parseImport = function() {
var node = this.startNode()
this.next()
if (this.tok.type === __acorn.tokTypes.string) {
node.specifiers = []
node.source = this.parseExprAtom()
node.kind = ''
} else {
var elt
if (this.tok.type === __acorn.tokTypes.name && this.tok.value !== "from") {
elt = this.startNode()
elt.local = this.parseIdent()
this.finishNode(elt, "ImportDefaultSpecifier")
this.eat(__acorn.tokTypes.comma)
}
return elts
node.specifiers = this.parseImportSpecifierList()
node.source = this.eatContextual("from") && this.tok.type == __acorn.tokTypes.string ? this.parseExprAtom() : this.dummyString()
if (elt) node.specifiers.unshift(elt)
}
this.semicolon()
return this.finishNode(node, "ImportDeclaration")
}
lp$1.parseExportSpecifierList = function() {
var this$1 = this;
lp$1.parseImportSpecifierList = function() {
var this$1 = this;
var elts = []
var elts = []
if (this.tok.type === __acorn.tokTypes.star) {
var elt = this.startNode()
this.next()
elt.local = this.eatContextual("as") ? this.parseIdent() : this.dummyIdent()
elts.push(this.finishNode(elt, "ImportNamespaceSpecifier"))
} else {
var indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
this.pushCx()
this.eat(__acorn_js.tokTypes.braceL)
this.eat(__acorn.tokTypes.braceL)
if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
while (!this.closes(__acorn_js.tokTypes.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
if (this$1.isContextual("from")) break
var elt = this$1.startNode()
elt.local = this$1.parseIdent()
if (isDummy(elt.local)) break
elt.exported = this$1.eatContextual("as") ? this$1.parseIdent() : elt.local
this$1.finishNode(elt, "ExportSpecifier")
elts.push(elt)
this$1.eat(__acorn_js.tokTypes.comma)
while (!this.closes(__acorn.tokTypes.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
var elt$1 = this$1.startNode()
if (this$1.eat(__acorn.tokTypes.star)) {
elt$1.local = this$1.eatContextual("as") ? this$1.parseIdent() : this$1.dummyIdent()
this$1.finishNode(elt$1, "ImportNamespaceSpecifier")
} else {
if (this$1.isContextual("from")) break
elt$1.imported = this$1.parseIdent()
if (isDummy(elt$1.imported)) break
elt$1.local = this$1.eatContextual("as") ? this$1.parseIdent() : elt$1.imported
this$1.finishNode(elt$1, "ImportSpecifier")
}
elts.push(elt$1)
this$1.eat(__acorn.tokTypes.comma)
}
this.eat(__acorn_js.tokTypes.braceR)
this.eat(__acorn.tokTypes.braceR)
this.popCx()
return elts
}
return elts
}
var lp$2 = LooseParser.prototype
lp$1.parseExportSpecifierList = function() {
var this$1 = this;
lp$2.checkLVal = function(expr) {
if (!expr) return expr
switch (expr.type) {
case "Identifier":
case "MemberExpression":
return expr
case "ParenthesizedExpression":
expr.expression = this.checkLVal(expr.expression)
return expr
default:
return this.dummyIdent()
}
var elts = []
var indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
this.pushCx()
this.eat(__acorn.tokTypes.braceL)
if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
while (!this.closes(__acorn.tokTypes.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
if (this$1.isContextual("from")) break
var elt = this$1.startNode()
elt.local = this$1.parseIdent()
if (isDummy(elt.local)) break
elt.exported = this$1.eatContextual("as") ? this$1.parseIdent() : elt.local
this$1.finishNode(elt, "ExportSpecifier")
elts.push(elt)
this$1.eat(__acorn.tokTypes.comma)
}
this.eat(__acorn.tokTypes.braceR)
this.popCx()
return elts
}
lp$2.parseExpression = function(noIn) {
var this$1 = this;
var lp$2 = LooseParser.prototype
var start = this.storeCurrentPos()
var expr = this.parseMaybeAssign(noIn)
if (this.tok.type === __acorn_js.tokTypes.comma) {
var node = this.startNodeAt(start)
node.expressions = [expr]
while (this.eat(__acorn_js.tokTypes.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn))
return this.finishNode(node, "SequenceExpression")
}
lp$2.checkLVal = function(expr) {
if (!expr) return expr
switch (expr.type) {
case "Identifier":
case "MemberExpression":
return expr
}
lp$2.parseParenExpression = function() {
this.pushCx()
this.expect(__acorn_js.tokTypes.parenL)
var val = this.parseExpression()
this.popCx()
this.expect(__acorn_js.tokTypes.parenR)
return val
case "ParenthesizedExpression":
expr.expression = this.checkLVal(expr.expression)
return expr
default:
return this.dummyIdent()
}
}
lp$2.parseMaybeAssign = function(noIn) {
if (this.toks.isContextual("yield")) {
var node = this.startNode()
this.next()
if (this.semicolon() || this.canInsertSemicolon() || (this.tok.type != __acorn_js.tokTypes.star && !this.tok.type.startsExpr)) {
node.delegate = false
node.argument = null
} else {
node.delegate = this.eat(__acorn_js.tokTypes.star)
node.argument = this.parseMaybeAssign()
}
return this.finishNode(node, "YieldExpression")
}
lp$2.parseExpression = function(noIn) {
var this$1 = this;
var start = this.storeCurrentPos()
var left = this.parseMaybeConditional(noIn)
if (this.tok.type.isAssign) {
var node$1 = this.startNodeAt(start)
node$1.operator = this.tok.value
node$1.left = this.tok.type === __acorn_js.tokTypes.eq ? this.toAssignable(left) : this.checkLVal(left)
this.next()
node$1.right = this.parseMaybeAssign(noIn)
return this.finishNode(node$1, "AssignmentExpression")
}
return left
var start = this.storeCurrentPos()
var expr = this.parseMaybeAssign(noIn)
if (this.tok.type === __acorn.tokTypes.comma) {
var node = this.startNodeAt(start)
node.expressions = [expr]
while (this.eat(__acorn.tokTypes.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn))
return this.finishNode(node, "SequenceExpression")
}
return expr
}
lp$2.parseMaybeConditional = function(noIn) {
var start = this.storeCurrentPos()
var expr = this.parseExprOps(noIn)
if (this.eat(__acorn_js.tokTypes.question)) {
var node = this.startNodeAt(start)
node.test = expr
node.consequent = this.parseMaybeAssign()
node.alternate = this.expect(__acorn_js.tokTypes.colon) ? this.parseMaybeAssign(noIn) : this.dummyIdent()
return this.finishNode(node, "ConditionalExpression")
lp$2.parseParenExpression = function() {
this.pushCx()
this.expect(__acorn.tokTypes.parenL)
var val = this.parseExpression()
this.popCx()
this.expect(__acorn.tokTypes.parenR)
return val
}
lp$2.parseMaybeAssign = function(noIn) {
if (this.toks.isContextual("yield")) {
var node = this.startNode()
this.next()
if (this.semicolon() || this.canInsertSemicolon() || (this.tok.type != __acorn.tokTypes.star && !this.tok.type.startsExpr)) {
node.delegate = false
node.argument = null
} else {
node.delegate = this.eat(__acorn.tokTypes.star)
node.argument = this.parseMaybeAssign()
}
return expr
return this.finishNode(node, "YieldExpression")
}
lp$2.parseExprOps = function(noIn) {
var start = this.storeCurrentPos()
var indent = this.curIndent, line = this.curLineStart
return this.parseExprOp(this.parseMaybeUnary(false), start, -1, noIn, indent, line)
var start = this.storeCurrentPos()
var left = this.parseMaybeConditional(noIn)
if (this.tok.type.isAssign) {
var node$1 = this.startNodeAt(start)
node$1.operator = this.tok.value
node$1.left = this.tok.type === __acorn.tokTypes.eq ? this.toAssignable(left) : this.checkLVal(left)
this.next()
node$1.right = this.parseMaybeAssign(noIn)
return this.finishNode(node$1, "AssignmentExpression")
}
return left
}
lp$2.parseExprOp = function(left, start, minPrec, noIn, indent, line) {
if (this.curLineStart != line && this.curIndent < indent && this.tokenStartsLine()) return left
var prec = this.tok.type.binop
if (prec != null && (!noIn || this.tok.type !== __acorn_js.tokTypes._in)) {
if (prec > minPrec) {
var node = this.startNodeAt(start)
node.left = left
node.operator = this.tok.value
this.next()
if (this.curLineStart != line && this.curIndent < indent && this.tokenStartsLine()) {
node.right = this.dummyIdent()
} else {
var rightStart = this.storeCurrentPos()
node.right = this.parseExprOp(this.parseMaybeUnary(false), rightStart, prec, noIn, indent, line)
}
this.finishNode(node, /&&|\|\|/.test(node.operator) ? "LogicalExpression" : "BinaryExpression")
return this.parseExprOp(node, start, minPrec, noIn, indent, line)
}
}
return left
lp$2.parseMaybeConditional = function(noIn) {
var start = this.storeCurrentPos()
var expr = this.parseExprOps(noIn)
if (this.eat(__acorn.tokTypes.question)) {
var node = this.startNodeAt(start)
node.test = expr
node.consequent = this.parseMaybeAssign()
node.alternate = this.expect(__acorn.tokTypes.colon) ? this.parseMaybeAssign(noIn) : this.dummyIdent()
return this.finishNode(node, "ConditionalExpression")
}
return expr
}
lp$2.parseMaybeUnary = function(sawUnary) {
var this$1 = this;
lp$2.parseExprOps = function(noIn) {
var start = this.storeCurrentPos()
var indent = this.curIndent, line = this.curLineStart
return this.parseExprOp(this.parseMaybeUnary(false), start, -1, noIn, indent, line)
}
var start = this.storeCurrentPos(), expr
if (this.options.ecmaVersion >= 8 && this.inAsync && this.toks.isContextual("await")) {
expr = this.parseAwait()
sawUnary = true
} else if (this.tok.type.prefix) {
var node = this.startNode(), update = this.tok.type === __acorn_js.tokTypes.incDec
if (!update) sawUnary = true
lp$2.parseExprOp = function(left, start, minPrec, noIn, indent, line) {
if (this.curLineStart != line && this.curIndent < indent && this.tokenStartsLine()) return left
var prec = this.tok.type.binop
if (prec != null && (!noIn || this.tok.type !== __acorn.tokTypes._in)) {
if (prec > minPrec) {
var node = this.startNodeAt(start)
node.left = left
node.operator = this.tok.value
node.prefix = true
this.next()
node.argument = this.parseMaybeUnary(true)
if (update) node.argument = this.checkLVal(node.argument)
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression")
} else if (this.tok.type === __acorn_js.tokTypes.ellipsis) {
var node$1 = this.startNode()
this.next()
node$1.argument = this.parseMaybeUnary(sawUnary)
expr = this.finishNode(node$1, "SpreadElement")
} else {
expr = this.parseExprSubscripts()
while (this.tok.type.postfix && !this.canInsertSemicolon()) {
var node$2 = this$1.startNodeAt(start)
node$2.operator = this$1.tok.value
node$2.prefix = false
node$2.argument = this$1.checkLVal(expr)
this$1.next()
expr = this$1.finishNode(node$2, "UpdateExpression")
if (this.curLineStart != line && this.curIndent < indent && this.tokenStartsLine()) {
node.right = this.dummyIdent()
} else {
var rightStart = this.storeCurrentPos()
node.right = this.parseExprOp(this.parseMaybeUnary(false), rightStart, prec, noIn, indent, line)
}
this.finishNode(node, /&&|\|\|/.test(node.operator) ? "LogicalExpression" : "BinaryExpression")
return this.parseExprOp(node, start, minPrec, noIn, indent, line)
}
}
return left
}
if (!sawUnary && this.eat(__acorn_js.tokTypes.starstar)) {
var node$3 = this.startNodeAt(start)
node$3.operator = "**"
node$3.left = expr
node$3.right = this.parseMaybeUnary(false)
return this.finishNode(node$3, "BinaryExpression")
lp$2.parseMaybeUnary = function(sawUnary) {
var this$1 = this;
var start = this.storeCurrentPos(), expr
if (this.options.ecmaVersion >= 8 && this.inAsync && this.toks.isContextual("await")) {
expr = this.parseAwait()
sawUnary = true
} else if (this.tok.type.prefix) {
var node = this.startNode(), update = this.tok.type === __acorn.tokTypes.incDec
if (!update) sawUnary = true
node.operator = this.tok.value
node.prefix = true
this.next()
node.argument = this.parseMaybeUnary(true)
if (update) node.argument = this.checkLVal(node.argument)
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression")
} else if (this.tok.type === __acorn.tokTypes.ellipsis) {
var node$1 = this.startNode()
this.next()
node$1.argument = this.parseMaybeUnary(sawUnary)
expr = this.finishNode(node$1, "SpreadElement")
} else {
expr = this.parseExprSubscripts()
while (this.tok.type.postfix && !this.canInsertSemicolon()) {
var node$2 = this$1.startNodeAt(start)
node$2.operator = this$1.tok.value
node$2.prefix = false
node$2.argument = this$1.checkLVal(expr)
this$1.next()
expr = this$1.finishNode(node$2, "UpdateExpression")
}
return expr
}
lp$2.parseExprSubscripts = function() {
var start = this.storeCurrentPos()
return this.parseSubscripts(this.parseExprAtom(), start, false, this.curIndent, this.curLineStart)
if (!sawUnary && this.eat(__acorn.tokTypes.starstar)) {
var node$3 = this.startNodeAt(start)
node$3.operator = "**"
node$3.left = expr
node$3.right = this.parseMaybeUnary(false)
return this.finishNode(node$3, "BinaryExpression")
}
lp$2.parseSubscripts = function(base, start, noCalls, startIndent, line) {
var this$1 = this;
return expr
}
for (;;) {
if (this$1.curLineStart != line && this$1.curIndent <= startIndent && this$1.tokenStartsLine()) {
if (this$1.tok.type == __acorn_js.tokTypes.dot && this$1.curIndent == startIndent)
--startIndent
else
return base
}
lp$2.parseExprSubscripts = function() {
var start = this.storeCurrentPos()
return this.parseSubscripts(this.parseExprAtom(), start, false, this.curIndent, this.curLineStart)
}
var maybeAsyncArrow = base.type === "Identifier" && base.name === "async" && !this$1.canInsertSemicolon()
lp$2.parseSubscripts = function(base, start, noCalls, startIndent, line) {
var this$1 = this;
if (this$1.eat(__acorn_js.tokTypes.dot)) {
var node = this$1.startNodeAt(start)
node.object = base
if (this$1.curLineStart != line && this$1.curIndent <= startIndent && this$1.tokenStartsLine())
node.property = this$1.dummyIdent()
else
node.property = this$1.parsePropertyAccessor() || this$1.dummyIdent()
node.computed = false
base = this$1.finishNode(node, "MemberExpression")
} else if (this$1.tok.type == __acorn_js.tokTypes.bracketL) {
this$1.pushCx()
this$1.next()
var node$1 = this$1.startNodeAt(start)
node$1.object = base
node$1.property = this$1.parseExpression()
node$1.computed = true
this$1.popCx()
this$1.expect(__acorn_js.tokTypes.bracketR)
base = this$1.finishNode(node$1, "MemberExpression")
} else if (!noCalls && this$1.tok.type == __acorn_js.tokTypes.parenL) {
var exprList = this$1.parseExprList(__acorn_js.tokTypes.parenR)
if (maybeAsyncArrow && this$1.eat(__acorn_js.tokTypes.arrow))
return this$1.parseArrowExpression(this$1.startNodeAt(start), exprList, true)
var node$2 = this$1.startNodeAt(start)
node$2.callee = base
node$2.arguments = exprList
base = this$1.finishNode(node$2, "CallExpression")
} else if (this$1.tok.type == __acorn_js.tokTypes.backQuote) {
var node$3 = this$1.startNodeAt(start)
node$3.tag = base
node$3.quasi = this$1.parseTemplate()
base = this$1.finishNode(node$3, "TaggedTemplateExpression")
} else {
for (;;) {
if (this$1.curLineStart != line && this$1.curIndent <= startIndent && this$1.tokenStartsLine()) {
if (this$1.tok.type == __acorn.tokTypes.dot && this$1.curIndent == startIndent)
--startIndent
else
return base
}
}
var maybeAsyncArrow = base.type === "Identifier" && base.name === "async" && !this$1.canInsertSemicolon()
if (this$1.eat(__acorn.tokTypes.dot)) {
var node = this$1.startNodeAt(start)
node.object = base
if (this$1.curLineStart != line && this$1.curIndent <= startIndent && this$1.tokenStartsLine())
node.property = this$1.dummyIdent()
else
node.property = this$1.parsePropertyAccessor() || this$1.dummyIdent()
node.computed = false
base = this$1.finishNode(node, "MemberExpression")
} else if (this$1.tok.type == __acorn.tokTypes.bracketL) {
this$1.pushCx()
this$1.next()
var node$1 = this$1.startNodeAt(start)
node$1.object = base
node$1.property = this$1.parseExpression()
node$1.computed = true
this$1.popCx()
this$1.expect(__acorn.tokTypes.bracketR)
base = this$1.finishNode(node$1, "MemberExpression")
} else if (!noCalls && this$1.tok.type == __acorn.tokTypes.parenL) {
var exprList = this$1.parseExprList(__acorn.tokTypes.parenR)
if (maybeAsyncArrow && this$1.eat(__acorn.tokTypes.arrow))
return this$1.parseArrowExpression(this$1.startNodeAt(start), exprList, true)
var node$2 = this$1.startNodeAt(start)
node$2.callee = base
node$2.arguments = exprList
base = this$1.finishNode(node$2, "CallExpression")
} else if (this$1.tok.type == __acorn.tokTypes.backQuote) {
var node$3 = this$1.startNodeAt(start)
node$3.tag = base
node$3.quasi = this$1.parseTemplate()
base = this$1.finishNode(node$3, "TaggedTemplateExpression")
} else {
return base
}
}
}
lp$2.parseExprAtom = function() {
var node
switch (this.tok.type) {
case __acorn_js.tokTypes._this:
case __acorn_js.tokTypes._super:
var type = this.tok.type === __acorn_js.tokTypes._this ? "ThisExpression" : "Super"
node = this.startNode()
this.next()
return this.finishNode(node, type)
lp$2.parseExprAtom = function() {
var node
switch (this.tok.type) {
case __acorn.tokTypes._this:
case __acorn.tokTypes._super:
var type = this.tok.type === __acorn.tokTypes._this ? "ThisExpression" : "Super"
node = this.startNode()
this.next()
return this.finishNode(node, type)
case __acorn_js.tokTypes.name:
var start = this.storeCurrentPos()
var id = this.parseIdent()
var isAsync = false
if (id.name === "async" && !this.canInsertSemicolon()) {
if (this.eat(__acorn_js.tokTypes._function))
return this.parseFunction(this.startNodeAt(start), false, true)
if (this.tok.type === __acorn_js.tokTypes.name) {
id = this.parseIdent()
isAsync = true
}
case __acorn.tokTypes.name:
var start = this.storeCurrentPos()
var id = this.parseIdent()
var isAsync = false
if (id.name === "async" && !this.canInsertSemicolon()) {
if (this.eat(__acorn.tokTypes._function))
return this.parseFunction(this.startNodeAt(start), false, true)
if (this.tok.type === __acorn.tokTypes.name) {
id = this.parseIdent()
isAsync = true
}
return this.eat(__acorn_js.tokTypes.arrow) ? this.parseArrowExpression(this.startNodeAt(start), [id], isAsync) : id
}
return this.eat(__acorn.tokTypes.arrow) ? this.parseArrowExpression(this.startNodeAt(start), [id], isAsync) : id
case __acorn_js.tokTypes.regexp:
node = this.startNode()
var val = this.tok.value
node.regex = {pattern: val.pattern, flags: val.flags}
node.value = val.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
this.next()
return this.finishNode(node, "Literal")
case __acorn.tokTypes.regexp:
node = this.startNode()
var val = this.tok.value
node.regex = {pattern: val.pattern, flags: val.flags}
node.value = val.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
this.next()
return this.finishNode(node, "Literal")
case __acorn_js.tokTypes.num: case __acorn_js.tokTypes.string:
node = this.startNode()
node.value = this.tok.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
this.next()
return this.finishNode(node, "Literal")
case __acorn.tokTypes.num: case __acorn.tokTypes.string:
node = this.startNode()
node.value = this.tok.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
this.next()
return this.finishNode(node, "Literal")
case __acorn_js.tokTypes._null: case __acorn_js.tokTypes._true: case __acorn_js.tokTypes._false:
node = this.startNode()
node.value = this.tok.type === __acorn_js.tokTypes._null ? null : this.tok.type === __acorn_js.tokTypes._true
node.raw = this.tok.type.keyword
this.next()
return this.finishNode(node, "Literal")
case __acorn.tokTypes._null: case __acorn.tokTypes._true: case __acorn.tokTypes._false:
node = this.startNode()
node.value = this.tok.type === __acorn.tokTypes._null ? null : this.tok.type === __acorn.tokTypes._true
node.raw = this.tok.type.keyword
this.next()
return this.finishNode(node, "Literal")
case __acorn_js.tokTypes.parenL:
var parenStart = this.storeCurrentPos()
this.next()
var inner = this.parseExpression()
this.expect(__acorn_js.tokTypes.parenR)
if (this.eat(__acorn_js.tokTypes.arrow)) {
// (a,)=>a // SequenceExpression makes dummy in the last hole. Drop the dummy.
var params = inner.expressions || [inner]
if (params.length && isDummy(params[params.length - 1]))
params.pop()
return this.parseArrowExpression(this.startNodeAt(parenStart), params)
}
if (this.options.preserveParens) {
var par = this.startNodeAt(parenStart)
par.expression = inner
inner = this.finishNode(par, "ParenthesizedExpression")
}
return inner
case __acorn.tokTypes.parenL:
var parenStart = this.storeCurrentPos()
this.next()
var inner = this.parseExpression()
this.expect(__acorn.tokTypes.parenR)
if (this.eat(__acorn.tokTypes.arrow)) {
// (a,)=>a // SequenceExpression makes dummy in the last hole. Drop the dummy.
var params = inner.expressions || [inner]
if (params.length && isDummy(params[params.length - 1]))
params.pop()
return this.parseArrowExpression(this.startNodeAt(parenStart), params)
}
if (this.options.preserveParens) {
var par = this.startNodeAt(parenStart)
par.expression = inner
inner = this.finishNode(par, "ParenthesizedExpression")
}
return inner
case __acorn_js.tokTypes.bracketL:
node = this.startNode()
node.elements = this.parseExprList(__acorn_js.tokTypes.bracketR, true)
return this.finishNode(node, "ArrayExpression")
case __acorn.tokTypes.bracketL:
node = this.startNode()
node.elements = this.parseExprList(__acorn.tokTypes.bracketR, true)
return this.finishNode(node, "ArrayExpression")
case __acorn_js.tokTypes.braceL:
return this.parseObj()
case __acorn.tokTypes.braceL:
return this.parseObj()
case __acorn_js.tokTypes._class:
return this.parseClass()
case __acorn.tokTypes._class:
return this.parseClass()
case __acorn_js.tokTypes._function:
node = this.startNode()
this.next()
return this.parseFunction(node, false)
case __acorn.tokTypes._function:
node = this.startNode()
this.next()
return this.parseFunction(node, false)
case __acorn_js.tokTypes._new:
return this.parseNew()
case __acorn.tokTypes._new:
return this.parseNew()
case __acorn_js.tokTypes.backQuote:
return this.parseTemplate()
case __acorn.tokTypes.backQuote:
return this.parseTemplate()
default:
return this.dummyIdent()
}
default:
return this.dummyIdent()
}
}
lp$2.parseNew = function() {
var node = this.startNode(), startIndent = this.curIndent, line = this.curLineStart
var meta = this.parseIdent(true)
if (this.options.ecmaVersion >= 6 && this.eat(__acorn_js.tokTypes.dot)) {
node.meta = meta
node.property = this.parseIdent(true)
return this.finishNode(node, "MetaProperty")
}
var start = this.storeCurrentPos()
node.callee = this.parseSubscripts(this.parseExprAtom(), start, true, startIndent, line)
if (this.tok.type == __acorn_js.tokTypes.parenL) {
node.arguments = this.parseExprList(__acorn_js.tokTypes.parenR)
} else {
node.arguments = []
}
return this.finishNode(node, "NewExpression")
lp$2.parseNew = function() {
var node = this.startNode(), startIndent = this.curIndent, line = this.curLineStart
var meta = this.parseIdent(true)
if (this.options.ecmaVersion >= 6 && this.eat(__acorn.tokTypes.dot)) {
node.meta = meta
node.property = this.parseIdent(true)
return this.finishNode(node, "MetaProperty")
}
var start = this.storeCurrentPos()
node.callee = this.parseSubscripts(this.parseExprAtom(), start, true, startIndent, line)
if (this.tok.type == __acorn.tokTypes.parenL) {
node.arguments = this.parseExprList(__acorn.tokTypes.parenR)
} else {
node.arguments = []
}
return this.finishNode(node, "NewExpression")
}
lp$2.parseTemplateElement = function() {
var elem = this.startNode()
elem.value = {
raw: this.input.slice(this.tok.start, this.tok.end).replace(/\r\n?/g, '\n'),
cooked: this.tok.value
}
this.next()
elem.tail = this.tok.type === __acorn_js.tokTypes.backQuote
return this.finishNode(elem, "TemplateElement")
lp$2.parseTemplateElement = function() {
var elem = this.startNode()
elem.value = {
raw: this.input.slice(this.tok.start, this.tok.end).replace(/\r\n?/g, '\n'),
cooked: this.tok.value
}
this.next()
elem.tail = this.tok.type === __acorn.tokTypes.backQuote
return this.finishNode(elem, "TemplateElement")
}
lp$2.parseTemplate = function() {
var this$1 = this;
lp$2.parseTemplate = function() {
var this$1 = this;
var node = this.startNode()
this.next()
node.expressions = []
var curElt = this.parseTemplateElement()
node.quasis = [curElt]
while (!curElt.tail) {
this$1.next()
node.expressions.push(this$1.parseExpression())
if (this$1.expect(__acorn_js.tokTypes.braceR)) {
curElt = this$1.parseTemplateElement()
} else {
curElt = this$1.startNode()
curElt.value = {cooked: '', raw: ''}
curElt.tail = true
this$1.finishNode(curElt, "TemplateElement")
}
node.quasis.push(curElt)
var node = this.startNode()
this.next()
node.expressions = []
var curElt = this.parseTemplateElement()
node.quasis = [curElt]
while (!curElt.tail) {
this$1.next()
node.expressions.push(this$1.parseExpression())
if (this$1.expect(__acorn.tokTypes.braceR)) {
curElt = this$1.parseTemplateElement()
} else {
curElt = this$1.startNode()
curElt.value = {cooked: '', raw: ''}
curElt.tail = true
this$1.finishNode(curElt, "TemplateElement")
}
this.expect(__acorn_js.tokTypes.backQuote)
return this.finishNode(node, "TemplateLiteral")
node.quasis.push(curElt)
}
this.expect(__acorn.tokTypes.backQuote)
return this.finishNode(node, "TemplateLiteral")
}
lp$2.parseObj = function() {
var this$1 = this;
lp$2.parseObj = function() {
var this$1 = this;
var node = this.startNode()
node.properties = []
this.pushCx()
var indent = this.curIndent + 1, line = this.curLineStart
this.eat(__acorn_js.tokTypes.braceL)
if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
while (!this.closes(__acorn_js.tokTypes.braceR, indent, line)) {
var prop = this$1.startNode(), isGenerator, isAsync, start
var node = this.startNode()
node.properties = []
this.pushCx()
var indent = this.curIndent + 1, line = this.curLineStart
this.eat(__acorn.tokTypes.braceL)
if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
while (!this.closes(__acorn.tokTypes.braceR, indent, line)) {
var prop = this$1.startNode(), isGenerator, isAsync, start
if (this$1.options.ecmaVersion >= 6) {
start = this$1.storeCurrentPos()
prop.method = false
prop.shorthand = false
isGenerator = this$1.eat(__acorn.tokTypes.star)
}
this$1.parsePropertyName(prop)
if (!prop.computed &&
prop.key.type === "Identifier" && prop.key.name === "async" && this$1.tok.type !== __acorn.tokTypes.parenL &&
this$1.tok.type !== __acorn.tokTypes.colon && !this$1.canInsertSemicolon()) {
this$1.parsePropertyName(prop)
isAsync = true
} else {
isAsync = false
}
if (isDummy(prop.key)) { if (isDummy(this$1.parseMaybeAssign())) this$1.next(); this$1.eat(__acorn.tokTypes.comma); continue }
if (this$1.eat(__acorn.tokTypes.colon)) {
prop.kind = "init"
prop.value = this$1.parseMaybeAssign()
} else if (this$1.options.ecmaVersion >= 6 && (this$1.tok.type === __acorn.tokTypes.parenL || this$1.tok.type === __acorn.tokTypes.braceL)) {
prop.kind = "init"
prop.method = true
prop.value = this$1.parseMethod(isGenerator, isAsync)
} else if (this$1.options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
!prop.computed && (prop.key.name === "get" || prop.key.name === "set") &&
(this$1.tok.type != __acorn.tokTypes.comma && this$1.tok.type != __acorn.tokTypes.braceR)) {
prop.kind = prop.key.name
this$1.parsePropertyName(prop)
prop.value = this$1.parseMethod(false)
} else {
prop.kind = "init"
if (this$1.options.ecmaVersion >= 6) {
start = this$1.storeCurrentPos()
prop.method = false
prop.shorthand = false
isGenerator = this$1.eat(__acorn_js.tokTypes.star)
}
this$1.parsePropertyName(prop)
if (!prop.computed &&
prop.key.type === "Identifier" && prop.key.name === "async" && this$1.tok.type !== __acorn_js.tokTypes.parenL &&
this$1.tok.type !== __acorn_js.tokTypes.colon && !this$1.canInsertSemicolon()) {
this$1.parsePropertyName(prop)
isAsync = true
} else {
isAsync = false
}
if (isDummy(prop.key)) { if (isDummy(this$1.parseMaybeAssign())) this$1.next(); this$1.eat(__acorn_js.tokTypes.comma); continue }
if (this$1.eat(__acorn_js.tokTypes.colon)) {
prop.kind = "init"
prop.value = this$1.parseMaybeAssign()
} else if (this$1.options.ecmaVersion >= 6 && (this$1.tok.type === __acorn_js.tokTypes.parenL || this$1.tok.type === __acorn_js.tokTypes.braceL)) {
prop.kind = "init"
prop.method = true
prop.value = this$1.parseMethod(isGenerator, isAsync)
} else if (this$1.options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
!prop.computed && (prop.key.name === "get" || prop.key.name === "set") &&
(this$1.tok.type != __acorn_js.tokTypes.comma && this$1.tok.type != __acorn_js.tokTypes.braceR)) {
prop.kind = prop.key.name
this$1.parsePropertyName(prop)
prop.value = this$1.parseMethod(false)
} else {
prop.kind = "init"
if (this$1.options.ecmaVersion >= 6) {
if (this$1.eat(__acorn_js.tokTypes.eq)) {
var assign = this$1.startNodeAt(start)
assign.operator = "="
assign.left = prop.key
assign.right = this$1.parseMaybeAssign()
prop.value = this$1.finishNode(assign, "AssignmentExpression")
} else {
prop.value = prop.key
}
if (this$1.eat(__acorn.tokTypes.eq)) {
var assign = this$1.startNodeAt(start)
assign.operator = "="
assign.left = prop.key
assign.right = this$1.parseMaybeAssign()
prop.value = this$1.finishNode(assign, "AssignmentExpression")
} else {
prop.value = this$1.dummyIdent()
prop.value = prop.key
}
prop.shorthand = true
} else {
prop.value = this$1.dummyIdent()
}
node.properties.push(this$1.finishNode(prop, "Property"))
this$1.eat(__acorn_js.tokTypes.comma)
prop.shorthand = true
}
this.popCx()
if (!this.eat(__acorn_js.tokTypes.braceR)) {
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
this.last.end = this.tok.start
if (this.options.locations) this.last.loc.end = this.tok.loc.start
}
return this.finishNode(node, "ObjectExpression")
node.properties.push(this$1.finishNode(prop, "Property"))
this$1.eat(__acorn.tokTypes.comma)
}
this.popCx()
if (!this.eat(__acorn.tokTypes.braceR)) {
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
this.last.end = this.tok.start
if (this.options.locations) this.last.loc.end = this.tok.loc.start
}
return this.finishNode(node, "ObjectExpression")
}
lp$2.parsePropertyName = function(prop) {
if (this.options.ecmaVersion >= 6) {
if (this.eat(__acorn_js.tokTypes.bracketL)) {
prop.computed = true
prop.key = this.parseExpression()
this.expect(__acorn_js.tokTypes.bracketR)
return
} else {
prop.computed = false
}
lp$2.parsePropertyName = function(prop) {
if (this.options.ecmaVersion >= 6) {
if (this.eat(__acorn.tokTypes.bracketL)) {
prop.computed = true
prop.key = this.parseExpression()
this.expect(__acorn.tokTypes.bracketR)
return
} else {
prop.computed = false
}
var key = (this.tok.type === __acorn_js.tokTypes.num || this.tok.type === __acorn_js.tokTypes.string) ? this.parseExprAtom() : this.parseIdent()
prop.key = key || this.dummyIdent()
}
var key = (this.tok.type === __acorn.tokTypes.num || this.tok.type === __acorn.tokTypes.string) ? this.parseExprAtom() : this.parseIdent()
prop.key = key || this.dummyIdent()
}
lp$2.parsePropertyAccessor = function() {
if (this.tok.type === __acorn_js.tokTypes.name || this.tok.type.keyword) return this.parseIdent()
}
lp$2.parsePropertyAccessor = function() {
if (this.tok.type === __acorn.tokTypes.name || this.tok.type.keyword) return this.parseIdent()
}
lp$2.parseIdent = function() {
var name = this.tok.type === __acorn_js.tokTypes.name ? this.tok.value : this.tok.type.keyword
if (!name) return this.dummyIdent()
var node = this.startNode()
this.next()
node.name = name
return this.finishNode(node, "Identifier")
}
lp$2.parseIdent = function() {
var name = this.tok.type === __acorn.tokTypes.name ? this.tok.value : this.tok.type.keyword
if (!name) return this.dummyIdent()
var node = this.startNode()
this.next()
node.name = name
return this.finishNode(node, "Identifier")
}
lp$2.initFunction = function(node) {
node.id = null
node.params = []
if (this.options.ecmaVersion >= 6) {
node.generator = false
node.expression = false
}
if (this.options.ecmaVersion >= 8)
node.async = false
lp$2.initFunction = function(node) {
node.id = null
node.params = []
if (this.options.ecmaVersion >= 6) {
node.generator = false
node.expression = false
}
if (this.options.ecmaVersion >= 8)
node.async = false
}
// Convert existing expression atom to assignable pattern
// if possible.
// Convert existing expression atom to assignable pattern
// if possible.
lp$2.toAssignable = function(node, binding) {
var this$1 = this;
lp$2.toAssignable = function(node, binding) {
var this$1 = this;
if (!node || node.type == "Identifier" || (node.type == "MemberExpression" && !binding)) {
// Okay
} else if (node.type == "ParenthesizedExpression") {
node.expression = this.toAssignable(node.expression, binding)
} else if (this.options.ecmaVersion < 6) {
return this.dummyIdent()
} else if (node.type == "ObjectExpression") {
node.type = "ObjectPattern"
var props = node.properties
for (var i = 0; i < props.length; i++)
props[i].value = this$1.toAssignable(props[i].value, binding)
} else if (node.type == "ArrayExpression") {
node.type = "ArrayPattern"
this.toAssignableList(node.elements, binding)
} else if (node.type == "SpreadElement") {
node.type = "RestElement"
node.argument = this.toAssignable(node.argument, binding)
} else if (node.type == "AssignmentExpression") {
node.type = "AssignmentPattern"
delete node.operator
} else {
return this.dummyIdent()
}
return node
if (!node || node.type == "Identifier" || (node.type == "MemberExpression" && !binding)) {
// Okay
} else if (node.type == "ParenthesizedExpression") {
node.expression = this.toAssignable(node.expression, binding)
} else if (this.options.ecmaVersion < 6) {
return this.dummyIdent()
} else if (node.type == "ObjectExpression") {
node.type = "ObjectPattern"
var props = node.properties
for (var i = 0; i < props.length; i++)
props[i].value = this$1.toAssignable(props[i].value, binding)
} else if (node.type == "ArrayExpression") {
node.type = "ArrayPattern"
this.toAssignableList(node.elements, binding)
} else if (node.type == "SpreadElement") {
node.type = "RestElement"
node.argument = this.toAssignable(node.argument, binding)
} else if (node.type == "AssignmentExpression") {
node.type = "AssignmentPattern"
delete node.operator
} else {
return this.dummyIdent()
}
return node
}
lp$2.toAssignableList = function(exprList, binding) {
var this$1 = this;
lp$2.toAssignableList = function(exprList, binding) {
var this$1 = this;
for (var i = 0; i < exprList.length; i++)
exprList[i] = this$1.toAssignable(exprList[i], binding)
return exprList
}
for (var i = 0; i < exprList.length; i++)
exprList[i] = this$1.toAssignable(exprList[i], binding)
return exprList
}
lp$2.parseFunctionParams = function(params) {
params = this.parseExprList(__acorn_js.tokTypes.parenR)
return this.toAssignableList(params, true)
}
lp$2.parseFunctionParams = function(params) {
params = this.parseExprList(__acorn.tokTypes.parenR)
return this.toAssignableList(params, true)
}
lp$2.parseMethod = function(isGenerator, isAsync) {
var node = this.startNode(), oldInAsync = this.inAsync
this.initFunction(node)
if (this.options.ecmaVersion >= 6)
node.generator = !!isGenerator
if (this.options.ecmaVersion >= 8)
node.async = !!isAsync
this.inAsync = node.async
node.params = this.parseFunctionParams()
node.expression = this.options.ecmaVersion >= 6 && this.tok.type !== __acorn_js.tokTypes.braceL
node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock()
this.inAsync = oldInAsync
return this.finishNode(node, "FunctionExpression")
}
lp$2.parseMethod = function(isGenerator, isAsync) {
var node = this.startNode(), oldInAsync = this.inAsync
this.initFunction(node)
if (this.options.ecmaVersion >= 6)
node.generator = !!isGenerator
if (this.options.ecmaVersion >= 8)
node.async = !!isAsync
this.inAsync = node.async
node.params = this.parseFunctionParams()
node.expression = this.options.ecmaVersion >= 6 && this.tok.type !== __acorn.tokTypes.braceL
node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock()
this.inAsync = oldInAsync
return this.finishNode(node, "FunctionExpression")
}
lp$2.parseArrowExpression = function(node, params, isAsync) {
var oldInAsync = this.inAsync
this.initFunction(node)
if (this.options.ecmaVersion >= 8)
node.async = !!isAsync
this.inAsync = node.async
node.params = this.toAssignableList(params, true)
node.expression = this.tok.type !== __acorn_js.tokTypes.braceL
node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock()
this.inAsync = oldInAsync
return this.finishNode(node, "ArrowFunctionExpression")
}
lp$2.parseArrowExpression = function(node, params, isAsync) {
var oldInAsync = this.inAsync
this.initFunction(node)
if (this.options.ecmaVersion >= 8)
node.async = !!isAsync
this.inAsync = node.async
node.params = this.toAssignableList(params, true)
node.expression = this.tok.type !== __acorn.tokTypes.braceL
node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock()
this.inAsync = oldInAsync
return this.finishNode(node, "ArrowFunctionExpression")
}
lp$2.parseExprList = function(close, allowEmpty) {
var this$1 = this;
lp$2.parseExprList = function(close, allowEmpty) {
var this$1 = this;
this.pushCx()
var indent = this.curIndent, line = this.curLineStart, elts = []
this.next() // Opening bracket
while (!this.closes(close, indent + 1, line)) {
if (this$1.eat(__acorn_js.tokTypes.comma)) {
elts.push(allowEmpty ? null : this$1.dummyIdent())
continue
}
var elt = this$1.parseMaybeAssign()
if (isDummy(elt)) {
if (this$1.closes(close, indent, line)) break
this$1.next()
} else {
elts.push(elt)
}
this$1.eat(__acorn_js.tokTypes.comma)
this.pushCx()
var indent = this.curIndent, line = this.curLineStart, elts = []
this.next() // Opening bracket
while (!this.closes(close, indent + 1, line)) {
if (this$1.eat(__acorn.tokTypes.comma)) {
elts.push(allowEmpty ? null : this$1.dummyIdent())
continue
}
this.popCx()
if (!this.eat(close)) {
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
this.last.end = this.tok.start
if (this.options.locations) this.last.loc.end = this.tok.loc.start
var elt = this$1.parseMaybeAssign()
if (isDummy(elt)) {
if (this$1.closes(close, indent, line)) break
this$1.next()
} else {
elts.push(elt)
}
return elts
this$1.eat(__acorn.tokTypes.comma)
}
lp$2.parseAwait = function() {
var node = this.startNode()
this.next()
node.argument = this.parseMaybeUnary()
return this.finishNode(node, "AwaitExpression")
this.popCx()
if (!this.eat(close)) {
// If there is no closing brace, make the node span to the start
// of the next token (this is useful for Tern)
this.last.end = this.tok.start
if (this.options.locations) this.last.loc.end = this.tok.loc.start
}
return elts
}
__acorn_js.defaultOptions.tabSize = 4
lp$2.parseAwait = function() {
var node = this.startNode()
this.next()
node.argument = this.parseMaybeUnary()
return this.finishNode(node, "AwaitExpression")
}
function parse_dammit(input, options) {
var p = new LooseParser(input, options)
p.next()
return p.parseTopLevel()
}
// Acorn: Loose parser
//
// This module provides an alternative parser (`parse_dammit`) that
// exposes that same interface as `parse`, but will try to parse
// anything as JavaScript, repairing syntax error the best it can.
// There are circumstances in which it will raise an error and give
// up, but they are very rare. The resulting AST will be a mostly
// valid JavaScript AST (as per the [Mozilla parser API][api], except
// that:
//
// - Return outside functions is allowed
//
// - Label consistency (no conflicts, break only to existing labels)
// is not enforced.
//
// - Bogus Identifier nodes with a name of `"✖"` are inserted whenever
// the parser got too confused to return anything meaningful.
//
// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
//
// The expected use for this is to *first* try `acorn.parse`, and only
// if that fails switch to `parse_dammit`. The loose parser might
// parse badly indented code incorrectly, so **don't** use it as
// your default parser.
//
// Quite a lot of acorn.js is duplicated here. The alternative was to
// add a *lot* of extra cruft to that file, making it less readable
// and slower. Copying and editing the code allowed me to make
// invasive changes and simplifications without creating a complicated
// tangle.
__acorn_js.addLooseExports(parse_dammit, LooseParser, pluginsLoose)
__acorn.defaultOptions.tabSize = 4
exports.parse_dammit = parse_dammit;
exports.LooseParser = LooseParser;
exports.pluginsLoose = pluginsLoose;
function parse_dammit(input, options) {
var p = new LooseParser(input, options)
p.next()
return p.parseTopLevel()
}
Object.defineProperty(exports, '__esModule', { value: true });
__acorn.addLooseExports(parse_dammit, LooseParser, pluginsLoose)
}));
exports.parse_dammit = parse_dammit;
exports.LooseParser = LooseParser;
exports.pluginsLoose = pluginsLoose;
Object.defineProperty(exports, '__esModule', { value: true });
})));

@@ -5,357 +5,357 @@ (function (global, factory) {

(factory((global.acorn = global.acorn || {}, global.acorn.walk = global.acorn.walk || {})));
}(this, function (exports) { 'use strict';
}(this, (function (exports) { 'use strict';
// AST walker module for Mozilla Parser API compatible trees
// AST walker module for Mozilla Parser API compatible trees
// A simple walk is one where you simply specify callbacks to be
// called on specific nodes. The last two arguments are optional. A
// simple use would be
//
// walk.simple(myTree, {
// Expression: function(node) { ... }
// });
//
// to do something with all expressions. All Parser API node types
// can be used to identify node types, as well as Expression,
// Statement, and ScopeBody, which denote categories of nodes.
//
// The base argument can be used to pass a custom (recursive)
// walker, and state can be used to give this walked an initial
// state.
// A simple walk is one where you simply specify callbacks to be
// called on specific nodes. The last two arguments are optional. A
// simple use would be
//
// walk.simple(myTree, {
// Expression: function(node) { ... }
// });
//
// to do something with all expressions. All Parser API node types
// can be used to identify node types, as well as Expression,
// Statement, and ScopeBody, which denote categories of nodes.
//
// The base argument can be used to pass a custom (recursive)
// walker, and state can be used to give this walked an initial
// state.
function simple(node, visitors, base, state, override) {
if (!base) base = exports.base
;(function c(node, st, override) {
var type = override || node.type, found = visitors[type]
base[type](node, st, c)
if (found) found(node, st)
})(node, state, override)
}
function simple(node, visitors, base, state, override) {
if (!base) base = exports.base
;(function c(node, st, override) {
var type = override || node.type, found = visitors[type]
base[type](node, st, c)
if (found) found(node, st)
})(node, state, override)
}
// An ancestor walk keeps an array of ancestor nodes (including the
// current node) and passes them to the callback as third parameter
// (and also as state parameter when no other state is present).
function ancestor(node, visitors, base, state) {
if (!base) base = exports.base
var ancestors = []
;(function c(node, st, override) {
var type = override || node.type, found = visitors[type]
var isNew = node != ancestors[ancestors.length - 1]
if (isNew) ancestors.push(node)
base[type](node, st, c)
if (found) found(node, st || ancestors, ancestors)
if (isNew) ancestors.pop()
})(node, state)
}
// An ancestor walk keeps an array of ancestor nodes (including the
// current node) and passes them to the callback as third parameter
// (and also as state parameter when no other state is present).
function ancestor(node, visitors, base, state) {
if (!base) base = exports.base
var ancestors = []
;(function c(node, st, override) {
var type = override || node.type, found = visitors[type]
var isNew = node != ancestors[ancestors.length - 1]
if (isNew) ancestors.push(node)
base[type](node, st, c)
if (found) found(node, st || ancestors, ancestors)
if (isNew) ancestors.pop()
})(node, state)
}
// A recursive walk is one where your functions override the default
// walkers. They can modify and replace the state parameter that's
// threaded through the walk, and can opt how and whether to walk
// their child nodes (by calling their third argument on these
// nodes).
function recursive(node, state, funcs, base, override) {
var visitor = funcs ? exports.make(funcs, base) : base
;(function c(node, st, override) {
visitor[override || node.type](node, st, c)
})(node, state, override)
}
// A recursive walk is one where your functions override the default
// walkers. They can modify and replace the state parameter that's
// threaded through the walk, and can opt how and whether to walk
// their child nodes (by calling their third argument on these
// nodes).
function recursive(node, state, funcs, base, override) {
var visitor = funcs ? exports.make(funcs, base) : base
;(function c(node, st, override) {
visitor[override || node.type](node, st, c)
})(node, state, override)
}
function makeTest(test) {
if (typeof test == "string")
return function (type) { return type == test; }
else if (!test)
return function () { return true; }
else
return test
}
function makeTest(test) {
if (typeof test == "string")
return function (type) { return type == test; }
else if (!test)
return function () { return true; }
else
return test
}
var Found = function Found(node, state) { this.node = node; this.state = state };
var Found = function Found(node, state) { this.node = node; this.state = state };
// Find a node with a given start, end, and type (all are optional,
// null can be used as wildcard). Returns a {node, state} object, or
// undefined when it doesn't find a matching node.
function findNodeAt(node, start, end, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
try {
;(function c(node, st, override) {
var type = override || node.type
if ((start == null || node.start <= start) &&
(end == null || node.end >= end))
base[type](node, st, c)
if ((start == null || node.start == start) &&
(end == null || node.end == end) &&
test(type, node))
throw new Found(node, st)
})(node, state)
} catch (e) {
if (e instanceof Found) return e
throw e
}
}
// Find the innermost node of a given type that contains the given
// position. Interface similar to findNodeAt.
function findNodeAround(node, pos, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
try {
;(function c(node, st, override) {
var type = override || node.type
if (node.start > pos || node.end < pos) return
// Find a node with a given start, end, and type (all are optional,
// null can be used as wildcard). Returns a {node, state} object, or
// undefined when it doesn't find a matching node.
function findNodeAt(node, start, end, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
try {
;(function c(node, st, override) {
var type = override || node.type
if ((start == null || node.start <= start) &&
(end == null || node.end >= end))
base[type](node, st, c)
if (test(type, node)) throw new Found(node, st)
})(node, state)
} catch (e) {
if (e instanceof Found) return e
throw e
}
if ((start == null || node.start == start) &&
(end == null || node.end == end) &&
test(type, node))
throw new Found(node, st)
})(node, state)
} catch (e) {
if (e instanceof Found) return e
throw e
}
}
// Find the outermost matching node after a given position.
function findNodeAfter(node, pos, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
try {
;(function c(node, st, override) {
if (node.end < pos) return
var type = override || node.type
if (node.start >= pos && test(type, node)) throw new Found(node, st)
base[type](node, st, c)
})(node, state)
} catch (e) {
if (e instanceof Found) return e
throw e
}
// Find the innermost node of a given type that contains the given
// position. Interface similar to findNodeAt.
function findNodeAround(node, pos, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
try {
;(function c(node, st, override) {
var type = override || node.type
if (node.start > pos || node.end < pos) return
base[type](node, st, c)
if (test(type, node)) throw new Found(node, st)
})(node, state)
} catch (e) {
if (e instanceof Found) return e
throw e
}
}
// Find the outermost matching node before a given position.
function findNodeBefore(node, pos, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
var max
// Find the outermost matching node after a given position.
function findNodeAfter(node, pos, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
try {
;(function c(node, st, override) {
if (node.start > pos) return
if (node.end < pos) return
var type = override || node.type
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
max = new Found(node, st)
if (node.start >= pos && test(type, node)) throw new Found(node, st)
base[type](node, st, c)
})(node, state)
return max
} catch (e) {
if (e instanceof Found) return e
throw e
}
}
// Fallback to an Object.create polyfill for older environments.
var create = Object.create || function(proto) {
function Ctor() {}
Ctor.prototype = proto
return new Ctor
}
// Find the outermost matching node before a given position.
function findNodeBefore(node, pos, test, base, state) {
test = makeTest(test)
if (!base) base = exports.base
var max
;(function c(node, st, override) {
if (node.start > pos) return
var type = override || node.type
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
max = new Found(node, st)
base[type](node, st, c)
})(node, state)
return max
}
// Used to create a custom walker. Will fill in all missing node
// type properties with the defaults.
function make(funcs, base) {
if (!base) base = exports.base
var visitor = create(base)
for (var type in funcs) visitor[type] = funcs[type]
return visitor
}
// Fallback to an Object.create polyfill for older environments.
var create = Object.create || function(proto) {
function Ctor() {}
Ctor.prototype = proto
return new Ctor
}
function skipThrough(node, st, c) { c(node, st) }
function ignore(_node, _st, _c) {}
// Used to create a custom walker. Will fill in all missing node
// type properties with the defaults.
function make(funcs, base) {
if (!base) base = exports.base
var visitor = create(base)
for (var type in funcs) visitor[type] = funcs[type]
return visitor
}
// Node walkers.
function skipThrough(node, st, c) { c(node, st) }
function ignore(_node, _st, _c) {}
var base = {}
// Node walkers.
base.Program = base.BlockStatement = function (node, st, c) {
for (var i = 0; i < node.body.length; ++i)
c(node.body[i], st, "Statement")
}
base.Statement = skipThrough
base.EmptyStatement = ignore
base.ExpressionStatement = base.ParenthesizedExpression =
function (node, st, c) { return c(node.expression, st, "Expression"); }
base.IfStatement = function (node, st, c) {
c(node.test, st, "Expression")
c(node.consequent, st, "Statement")
if (node.alternate) c(node.alternate, st, "Statement")
}
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); }
base.BreakStatement = base.ContinueStatement = ignore
base.WithStatement = function (node, st, c) {
c(node.object, st, "Expression")
c(node.body, st, "Statement")
}
base.SwitchStatement = function (node, st, c) {
c(node.discriminant, st, "Expression")
for (var i = 0; i < node.cases.length; ++i) {
var cs = node.cases[i]
if (cs.test) c(cs.test, st, "Expression")
for (var j = 0; j < cs.consequent.length; ++j)
c(cs.consequent[j], st, "Statement")
}
}
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
if (node.argument) c(node.argument, st, "Expression")
}
base.ThrowStatement = base.SpreadElement =
function (node, st, c) { return c(node.argument, st, "Expression"); }
base.TryStatement = function (node, st, c) {
c(node.block, st, "Statement")
if (node.handler) c(node.handler, st)
if (node.finalizer) c(node.finalizer, st, "Statement")
}
base.CatchClause = function (node, st, c) {
c(node.param, st, "Pattern")
c(node.body, st, "ScopeBody")
}
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
c(node.test, st, "Expression")
c(node.body, st, "Statement")
}
base.ForStatement = function (node, st, c) {
if (node.init) c(node.init, st, "ForInit")
if (node.test) c(node.test, st, "Expression")
if (node.update) c(node.update, st, "Expression")
c(node.body, st, "Statement")
}
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
c(node.left, st, "ForInit")
c(node.right, st, "Expression")
c(node.body, st, "Statement")
}
base.ForInit = function (node, st, c) {
if (node.type == "VariableDeclaration") c(node, st)
else c(node, st, "Expression")
}
base.DebuggerStatement = ignore
var base = {}
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); }
base.VariableDeclaration = function (node, st, c) {
for (var i = 0; i < node.declarations.length; ++i)
c(node.declarations[i], st)
base.Program = base.BlockStatement = function (node, st, c) {
for (var i = 0; i < node.body.length; ++i)
c(node.body[i], st, "Statement")
}
base.Statement = skipThrough
base.EmptyStatement = ignore
base.ExpressionStatement = base.ParenthesizedExpression =
function (node, st, c) { return c(node.expression, st, "Expression"); }
base.IfStatement = function (node, st, c) {
c(node.test, st, "Expression")
c(node.consequent, st, "Statement")
if (node.alternate) c(node.alternate, st, "Statement")
}
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); }
base.BreakStatement = base.ContinueStatement = ignore
base.WithStatement = function (node, st, c) {
c(node.object, st, "Expression")
c(node.body, st, "Statement")
}
base.SwitchStatement = function (node, st, c) {
c(node.discriminant, st, "Expression")
for (var i = 0; i < node.cases.length; ++i) {
var cs = node.cases[i]
if (cs.test) c(cs.test, st, "Expression")
for (var j = 0; j < cs.consequent.length; ++j)
c(cs.consequent[j], st, "Statement")
}
base.VariableDeclarator = function (node, st, c) {
c(node.id, st, "Pattern")
if (node.init) c(node.init, st, "Expression")
}
}
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
if (node.argument) c(node.argument, st, "Expression")
}
base.ThrowStatement = base.SpreadElement =
function (node, st, c) { return c(node.argument, st, "Expression"); }
base.TryStatement = function (node, st, c) {
c(node.block, st, "Statement")
if (node.handler) c(node.handler, st)
if (node.finalizer) c(node.finalizer, st, "Statement")
}
base.CatchClause = function (node, st, c) {
c(node.param, st, "Pattern")
c(node.body, st, "ScopeBody")
}
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
c(node.test, st, "Expression")
c(node.body, st, "Statement")
}
base.ForStatement = function (node, st, c) {
if (node.init) c(node.init, st, "ForInit")
if (node.test) c(node.test, st, "Expression")
if (node.update) c(node.update, st, "Expression")
c(node.body, st, "Statement")
}
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
c(node.left, st, "ForInit")
c(node.right, st, "Expression")
c(node.body, st, "Statement")
}
base.ForInit = function (node, st, c) {
if (node.type == "VariableDeclaration") c(node, st)
else c(node, st, "Expression")
}
base.DebuggerStatement = ignore
base.Function = function (node, st, c) {
if (node.id) c(node.id, st, "Pattern")
for (var i = 0; i < node.params.length; i++)
c(node.params[i], st, "Pattern")
c(node.body, st, node.expression ? "ScopeExpression" : "ScopeBody")
}
// FIXME drop these node types in next major version
// (They are awkward, and in ES6 every block can be a scope.)
base.ScopeBody = function (node, st, c) { return c(node, st, "Statement"); }
base.ScopeExpression = function (node, st, c) { return c(node, st, "Expression"); }
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); }
base.VariableDeclaration = function (node, st, c) {
for (var i = 0; i < node.declarations.length; ++i)
c(node.declarations[i], st)
}
base.VariableDeclarator = function (node, st, c) {
c(node.id, st, "Pattern")
if (node.init) c(node.init, st, "Expression")
}
base.Pattern = function (node, st, c) {
if (node.type == "Identifier")
c(node, st, "VariablePattern")
else if (node.type == "MemberExpression")
c(node, st, "MemberPattern")
else
c(node, st)
}
base.VariablePattern = ignore
base.MemberPattern = skipThrough
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); }
base.ArrayPattern = function (node, st, c) {
for (var i = 0; i < node.elements.length; ++i) {
var elt = node.elements[i]
if (elt) c(elt, st, "Pattern")
}
}
base.ObjectPattern = function (node, st, c) {
for (var i = 0; i < node.properties.length; ++i)
c(node.properties[i].value, st, "Pattern")
}
base.Function = function (node, st, c) {
if (node.id) c(node.id, st, "Pattern")
for (var i = 0; i < node.params.length; i++)
c(node.params[i], st, "Pattern")
c(node.body, st, node.expression ? "ScopeExpression" : "ScopeBody")
}
// FIXME drop these node types in next major version
// (They are awkward, and in ES6 every block can be a scope.)
base.ScopeBody = function (node, st, c) { return c(node, st, "Statement"); }
base.ScopeExpression = function (node, st, c) { return c(node, st, "Expression"); }
base.Expression = skipThrough
base.ThisExpression = base.Super = base.MetaProperty = ignore
base.ArrayExpression = function (node, st, c) {
for (var i = 0; i < node.elements.length; ++i) {
var elt = node.elements[i]
if (elt) c(elt, st, "Expression")
}
base.Pattern = function (node, st, c) {
if (node.type == "Identifier")
c(node, st, "VariablePattern")
else if (node.type == "MemberExpression")
c(node, st, "MemberPattern")
else
c(node, st)
}
base.VariablePattern = ignore
base.MemberPattern = skipThrough
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); }
base.ArrayPattern = function (node, st, c) {
for (var i = 0; i < node.elements.length; ++i) {
var elt = node.elements[i]
if (elt) c(elt, st, "Pattern")
}
base.ObjectExpression = function (node, st, c) {
for (var i = 0; i < node.properties.length; ++i)
c(node.properties[i], st)
}
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration
base.SequenceExpression = base.TemplateLiteral = function (node, st, c) {
for (var i = 0; i < node.expressions.length; ++i)
c(node.expressions[i], st, "Expression")
}
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
c(node.argument, st, "Expression")
}
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
c(node.left, st, "Expression")
c(node.right, st, "Expression")
}
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
c(node.left, st, "Pattern")
c(node.right, st, "Expression")
}
base.ConditionalExpression = function (node, st, c) {
c(node.test, st, "Expression")
c(node.consequent, st, "Expression")
c(node.alternate, st, "Expression")
}
base.NewExpression = base.CallExpression = function (node, st, c) {
c(node.callee, st, "Expression")
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i)
c(node.arguments[i], st, "Expression")
}
base.MemberExpression = function (node, st, c) {
c(node.object, st, "Expression")
if (node.computed) c(node.property, st, "Expression")
}
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
if (node.declaration)
c(node.declaration, st, node.type == "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression")
if (node.source) c(node.source, st, "Expression")
}
base.ExportAllDeclaration = function (node, st, c) {
c(node.source, st, "Expression")
}
base.ImportDeclaration = function (node, st, c) {
for (var i = 0; i < node.specifiers.length; i++)
c(node.specifiers[i], st)
c(node.source, st, "Expression")
}
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore
}
base.ObjectPattern = function (node, st, c) {
for (var i = 0; i < node.properties.length; ++i)
c(node.properties[i].value, st, "Pattern")
}
base.TaggedTemplateExpression = function (node, st, c) {
c(node.tag, st, "Expression")
c(node.quasi, st)
base.Expression = skipThrough
base.ThisExpression = base.Super = base.MetaProperty = ignore
base.ArrayExpression = function (node, st, c) {
for (var i = 0; i < node.elements.length; ++i) {
var elt = node.elements[i]
if (elt) c(elt, st, "Expression")
}
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); }
base.Class = function (node, st, c) {
if (node.id) c(node.id, st, "Pattern")
if (node.superClass) c(node.superClass, st, "Expression")
for (var i = 0; i < node.body.body.length; i++)
c(node.body.body[i], st)
}
base.MethodDefinition = base.Property = function (node, st, c) {
if (node.computed) c(node.key, st, "Expression")
c(node.value, st, "Expression")
}
}
base.ObjectExpression = function (node, st, c) {
for (var i = 0; i < node.properties.length; ++i)
c(node.properties[i], st)
}
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration
base.SequenceExpression = base.TemplateLiteral = function (node, st, c) {
for (var i = 0; i < node.expressions.length; ++i)
c(node.expressions[i], st, "Expression")
}
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
c(node.argument, st, "Expression")
}
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
c(node.left, st, "Expression")
c(node.right, st, "Expression")
}
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
c(node.left, st, "Pattern")
c(node.right, st, "Expression")
}
base.ConditionalExpression = function (node, st, c) {
c(node.test, st, "Expression")
c(node.consequent, st, "Expression")
c(node.alternate, st, "Expression")
}
base.NewExpression = base.CallExpression = function (node, st, c) {
c(node.callee, st, "Expression")
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i)
c(node.arguments[i], st, "Expression")
}
base.MemberExpression = function (node, st, c) {
c(node.object, st, "Expression")
if (node.computed) c(node.property, st, "Expression")
}
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
if (node.declaration)
c(node.declaration, st, node.type == "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression")
if (node.source) c(node.source, st, "Expression")
}
base.ExportAllDeclaration = function (node, st, c) {
c(node.source, st, "Expression")
}
base.ImportDeclaration = function (node, st, c) {
for (var i = 0; i < node.specifiers.length; i++)
c(node.specifiers[i], st)
c(node.source, st, "Expression")
}
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore
exports.simple = simple;
exports.ancestor = ancestor;
exports.recursive = recursive;
exports.findNodeAt = findNodeAt;
exports.findNodeAround = findNodeAround;
exports.findNodeAfter = findNodeAfter;
exports.findNodeBefore = findNodeBefore;
exports.make = make;
exports.base = base;
base.TaggedTemplateExpression = function (node, st, c) {
c(node.tag, st, "Expression")
c(node.quasi, st)
}
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); }
base.Class = function (node, st, c) {
if (node.id) c(node.id, st, "Pattern")
if (node.superClass) c(node.superClass, st, "Expression")
for (var i = 0; i < node.body.body.length; i++)
c(node.body.body[i], st)
}
base.MethodDefinition = base.Property = function (node, st, c) {
if (node.computed) c(node.key, st, "Expression")
c(node.value, st, "Expression")
}
Object.defineProperty(exports, '__esModule', { value: true });
exports.simple = simple;
exports.ancestor = ancestor;
exports.recursive = recursive;
exports.findNodeAt = findNodeAt;
exports.findNodeAround = findNodeAround;
exports.findNodeAfter = findNodeAfter;
exports.findNodeBefore = findNodeBefore;
exports.make = make;
exports.base = base;
}));
Object.defineProperty(exports, '__esModule', { value: true });
})));

@@ -7,3 +7,3 @@ {

"jsnext:main": "dist/acorn.es.js",
"version": "4.0.3",
"version": "4.0.4",
"engines": {

@@ -10,0 +10,0 @@ "node": ">=0.4.0"

@@ -39,3 +39,3 @@ // Acorn is a tiny, fast JavaScript parser written in JavaScript.

export const version = "4.0.3"
export const version = "4.0.4"

@@ -42,0 +42,0 @@ // The main exported interface (under `self.acorn` when in the

@@ -658,3 +658,8 @@ import {types as tt} from "./tokentype"

pp.shouldParseExportStatement = function() {
return this.type.keyword || this.isLet() || this.isAsyncFunction()
return this.type.keyword === "var"
|| this.type.keyword === "const"
|| this.type.keyword === "class"
|| this.type.keyword === "function"
|| this.isLet()
|| this.isAsyncFunction()
}

@@ -661,0 +666,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc