summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/paca.mjs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/paca.mjs b/src/paca.mjs
index 7a01407..ccff1ca 100644
--- a/src/paca.mjs
+++ b/src/paca.mjs
@@ -24,7 +24,7 @@ const shouldConcat = (char, next) =>
char !== "{" &&
!nonConcatOperators.has(next);
-const operatorChars = new Set([...nonConcatOperators, "(", "."]);
+const operatorChars = new Set([...nonConcatOperators, "("]);
const isOperator = char =>
operatorChars.has(char);
@@ -167,8 +167,8 @@ const classStateStep = ({ out, state, context }, char, _index, _next) => {
return {
out: out.concat({
- operator: "class",
- set: context.set,
+ meta: "class",
+ set: context.set,
}),
state: ConcatStep.ACCEPTING,
context: null,
@@ -327,6 +327,15 @@ const transitionChars = new Set(Object.keys(TRANSITION_FNS));
const isTransition = char =>
transitionChars.has(char);
+const metaChars = new Set(["."]);
+const isMeta = char =>
+ metaChars.has(char);
+
+const opFor = char =>
+ isOperator(char) ? { operator: char }
+ : isMeta(char) ? { meta: char }
+ : char;
+
const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => {
const next = chars[index + 1];
@@ -357,10 +366,9 @@ const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => {
);
}
- const op = isOperator(char) ? { operator: char } : char;
return {
out: out.concat(
- op,
+ opFor(char),
shouldConcat(char, next)
? [{ operator: "concat" }]
: [],
@@ -398,8 +406,6 @@ const PRECEDENCE = {
"range": 3,
"concat": 2,
"|": 1,
- "class": 1,
- ".": 1,
};
const shouldPush = (stack, token) =>
@@ -414,7 +420,7 @@ const findLowerPrecedenceItem = (stack, token) =>
);
const toPostfixStep = ({ out, stack }, token, _index, tokens) => {
- if (typeof token === "string") {
+ if (!token.operator) {
return {
out: out.concat(token),
stack,