Skip to content

Commit

Permalink
refactor: fix comma-separated list case
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Nov 21, 2023
1 parent 1fbea18 commit 5b0e90e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,17 @@ function parseVariable(
j++ // skip ]
}

j++ // skip =
let value: AST | null = null

const right = readUntil(',', body, j)
const value = parseExpression(readUntil(',', body, j)) ?? prefix
j += right.length
const delimiter = body[j++]
if (delimiter?.value === '=') {
const right = readUntil(',', body, j)
j += right.length

declarations.push(new VariableDeclarator(name, value))
value = parseExpression(right.slice(0, -1))
}

declarations.push(new VariableDeclarator(name, value ?? prefix))
}

return new VariableDeclaration(layout, qualifiers, kind, type, declarations)
Expand Down

0 comments on commit 5b0e90e

Please sign in to comment.