Skip to content

Commit

Permalink
change loose parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Oct 27, 2024
1 parent 4a97a5d commit 847b359
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions acorn-loose/src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,31 +565,26 @@ lp.parseWithClause = function() {
this.eat(tt.braceL)
if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
while (!this.closes(tt.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
const attr = this.parseImportAttribute()
if (!attr) break
nodes.push(attr)
const attr = this.startNode()
attr.key = this.tok.type === tt.string ? this.parseExprAtom() : this.parseIdent()
if (this.eat(tt.colon)) {
if (this.tok.type === tt.string)
attr.value = this.parseExprAtom()
else attr.value = this.dummyString()
} else {
if (isDummy(attr.key)) break
if (this.tok.type === tt.string)
attr.value = this.parseExprAtom()
else break
}
nodes.push(this.finishNode(attr, "ImportAttribute"))
this.eat(tt.comma)
}
this.eat(tt.braceR)
this.popCx()
return nodes
}

lp.parseImportAttribute = function() {
const node = this.startNode()
node.key = this.tok.type === tt.string ? this.parseExprAtom() : this.parseIdent()
this.eat(tt.colon)
if (this.tok.type === tt.string) {
node.value = this.parseExprAtom()
} else {
if (isDummy(node.key)) {
return null
}
node.value = this.dummyString()
}
return this.finishNode(node, "ImportAttribute")
}

lp.parseExportSpecifierList = function() {
let elts = []
let indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
Expand Down

0 comments on commit 847b359

Please sign in to comment.