From b0983283d05ba4ad66c4e886a0a290b425b2991a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 11 Jul 2025 21:24:52 -0300 Subject: src/paca.mjs (tokenizeRegexStep): Fix missing concat when escaping --- src/paca.mjs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/paca.mjs b/src/paca.mjs index 078a824..b30d4cd 100644 --- a/src/paca.mjs +++ b/src/paca.mjs @@ -31,13 +31,13 @@ const numFromDigits = digits => const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => { const next = chars[index + 1]; - const maybeConcat = shouldConcat(char, next) - ? [{operator: "concat"}] - : []; if (state === ConcatStep.ESCAPING) { return { - out: out.concat(char, maybeConcat), + out: out.concat( + char, + next !== undefined ? {operator: "concat"} : [], + ), state: ConcatStep.ACCEPTING, context, }; @@ -143,7 +143,10 @@ const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => { const op = isOperator(char) ? { operator: char } : char; return { - out: out.concat(op, maybeConcat), + out: out.concat( + op, + shouldConcat(char, next) ? [{operator: "concat"}] : [], + ), state, context, }; -- cgit v1.2.3