diff --git a/static/ast-parser.js b/static/ast-parser.js index f9988a5..57528df 100644 --- a/static/ast-parser.js +++ b/static/ast-parser.js @@ -45,17 +45,17 @@ export function parseAstLog(text) { return root; } -const _REST_TOKEN = /(\w+)='([^']*)'|(\w+)=(\S+)|'([^']*)'|(\S+)/g; +const _REST_TOKEN = /(\w+=)?('[^']*'|\S+)/g; function _parseRest(rest) { const positionals = []; const props = {}; let inProps = false; - for (const [, kq, vq, kb, vb, qpos, bpos] of rest.matchAll(_REST_TOKEN)) { - if (kq !== undefined) { inProps = true; props[kq] = coerce(vq); } - else if (kb !== undefined) { inProps = true; props[kb] = coerce(vb); } - else if (!inProps) { positionals.push(coerce(qpos ?? bpos)); } + for (const [, keyEq, raw] of rest.matchAll(_REST_TOKEN)) { + const val = coerce(raw.startsWith("'") ? raw.slice(1, -1) : raw); + if (keyEq !== undefined) { inProps = true; props[keyEq.slice(0, -1)] = val; } + else if (!inProps) { positionals.push(val); } } return { positionals, props };