summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-07-11 21:24:52 -0300
committerEuAndreh <eu@euandre.org>2025-07-11 21:24:52 -0300
commitb0983283d05ba4ad66c4e886a0a290b425b2991a (patch)
tree53f00271112ca8c98898fe8b31cd7cc96d5702c4 /src
parenttests/paca.mjs: Add tests for numFromDigits() (diff)
downloadpaca-b0983283d05ba4ad66c4e886a0a290b425b2991a.tar.gz
paca-b0983283d05ba4ad66c4e886a0a290b425b2991a.tar.xz
src/paca.mjs (tokenizeRegexStep): Fix missing concat when escaping
Diffstat (limited to '')
-rw-r--r--src/paca.mjs13
1 files 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,
};