From ebcaf686e938e31e160bc0610df2a0c52c472ff9 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 11 Jul 2025 15:29:22 -0300 Subject: src/paca.mjs (tokenizeRegexStep): Include `context` key in reduced state --- src/paca.mjs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/paca.mjs') diff --git a/src/paca.mjs b/src/paca.mjs index 380200a..e68cd77 100644 --- a/src/paca.mjs +++ b/src/paca.mjs @@ -17,12 +17,13 @@ const shouldConcat = (char, next) => next !== undefined && char !== "(" && char !== "|" && + char !== "{" && !nonConcatOperators.has(next); const isOperator = char => nonConcatOperators.has(char) || char == "("; -const tokenizeRegexStep = chars => ({ out, state }, char, index) => { +const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => { const next = chars[index + 1]; const maybeConcat = shouldConcat(char, next) ? [{operator: "concat"}] @@ -32,6 +33,7 @@ const tokenizeRegexStep = chars => ({ out, state }, char, index) => { return { out: out.concat(char, maybeConcat), state: ConcatStep.ACCEPTING, + context, }; } @@ -39,6 +41,7 @@ const tokenizeRegexStep = chars => ({ out, state }, char, index) => { return { out, state: ConcatStep.ESCAPING, + context, }; } @@ -46,13 +49,15 @@ const tokenizeRegexStep = chars => ({ out, state }, char, index) => { return { out: out.concat(op, maybeConcat), state, + context, }; }; const tokenizeRegexFn = chars => chars.reduce(tokenizeRegexStep(chars), { - out: [], - state: ConcatStep.ACCEPTING, + out: [], + state: ConcatStep.ACCEPTING, + context: null, }); const tokenizeRegex = chars => { -- cgit v1.2.3