summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/paca.mjs11
1 files changed, 8 insertions, 3 deletions
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 => {