diff options
Diffstat (limited to 'src/paca.mjs')
| -rw-r--r-- | src/paca.mjs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/paca.mjs b/src/paca.mjs index b92bcdc..598c751 100644 --- a/src/paca.mjs +++ b/src/paca.mjs @@ -15,6 +15,15 @@ const ConcatStep = { CLASS: "class", }; +const nonConcatOperators = new Set(["*", "+", "?", "|", ")"]); + +const shouldConcat = (char, next) => + next !== undefined && + char !== "(" && + char !== "|" && + char !== "{" && + !nonConcatOperators.has(next); + const numFromDigits = digits => digits.length === 0 ? -1 @@ -23,7 +32,7 @@ const numFromDigits = digits => const escapingStateStep = ({ out, _state, context }, char, _index, next) => ({ out: out.concat( char, - next !== undefined ? {operator: "concat"} : [], + shouldConcat(null, next) ? [{ operator: "concat" }] : [], ), state: ConcatStep.ACCEPTING, context, @@ -265,15 +274,6 @@ const TRANSITION_FNS = { const stateTransitionOperators = new Set(Object.keys(TRANSITION_FNS)); -const nonConcatOperators = new Set(["*", "+", "?", "|", ")"]); - -const shouldConcat = (char, next) => - next !== undefined && - char !== "(" && - char !== "|" && - char !== "{" && - !nonConcatOperators.has(next); - const isOperator = char => nonConcatOperators.has(char) || char == "("; @@ -302,7 +302,7 @@ const tokenizeRegexStep = chars => ({ out, state, context }, char, index) => { return { out: out.concat( op, - shouldConcat(char, next) ? [{operator: "concat"}] : [], + shouldConcat(char, next) ? [{ operator: "concat" }] : [], ), state, context, |
