summaryrefslogtreecommitdiff
path: root/src/paca.mjs
diff options
context:
space:
mode:
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,
};